Replies: 1 comment
|
Cross-linking #7468 — same root-cause family (bundled userland undici 8 dispatcher installed by Your report adds two data points that matter for scoping, because #7468 is still pinning down exactly when the dispatcher gets installed (its symptom section and its root-cause note disagree on whether proxy env vars are required; see the follow-up discussion there):
Both threads converge on the same fix direction: don't override the global dispatcher across undici majors (or build it from the runtime's own undici), plus an explicit |
Uh oh!
There was an error while loading. Please reload this page.
web_search always fails: "DeepSeek returned an unprocessable response body" (brotli response not decoded when a custom undici dispatcher is installed)
Environment
@deepseek-ai/dsh0.1.7-alpha.1 (also reproduced on 0.1.1-rc.2 — the bug predates the 0.1.7 alpha)web(default)master:packages/web/web-search-deepseek/src/provider.tsstill issues a barefetch()with noaccept-encodinghandling.Summary
Every
web_searchtool call fails with:The model-facing
web_searchtool is completely unusable, whileweb_fetchstill works.Root cause
dsh-web-search-deepseek's provider calls barefetch()with noaccept-encodingheader, so the client advertisesgzip, deflate, br.https://api.deepseek.com/anthropic/v1/messages(served via CloudFront) responds withContent-Encoding: br(brotli).dsh-http-proxyimports userlandundici(8.11.0) at boot. undici 8.x mirrors its global dispatcher into the legacySymbol.for('undici.globalDispatcher.1')slot, so Node's built-infetchnow runs on a custom dispatcher even when no proxy is configured.fetchdoes not decode response content-encoding: theContent-Encodingheader comes back asnulland the body stays raw brotli bytes (gzip is equally undecoded).response.json()parses raw brotli bytes →SyntaxError: Unexpected token 'e', .... The'e'is byte0x65, the first byte of the brotli stream — hence"ePZ..."in the error.Evidence (all reproduced locally)
curlwithAccept-Encoding: gzip, deflate, brto the endpoint200 OK,Content-Encoding: br, body starts with hex65 00 10 2D ...(raw brotli)fetch, stock process (no undici loaded)200,Content-Encoding: br, body correctly decoded to JSONrequire('<dsh>/node_modules/undici')(installs the legacy global dispatcher slot)200,Content-Encoding: null, body is raw brotli →JSON.parsethrows the exact error aboveAccept-Encoding: gzip, deflateAccept-Encoding: identity200, uncompressed JSON, parses fine ✔Minimal repro (no dsh needed beyond the bundled undici):
Verified workaround
Setting
'accept-encoding': 'identity'on the search request makes the server return uncompressed JSON, which parses correctly. (Setting gzip alone does not help — the custom-dispatcher path leaves gzip undecoded too.)Suggested fixes
'accept-encoding': 'identity'to thefetchheaders inpackages/web/web-search-deepseek/src/provider.ts.undici8.x hijack Node's built-infetchwhen no proxy policy is actually active (thedsh-http-proxy"none" path still ends up with undici's default global Agent mirrored into the legacySymbol.for('undici.globalDispatcher.1')slot), or useundici's ownfetch— which decodes brotli correctly — for this request. Noteweb_fetchworks precisely becausedsh-web-fetch-httpuses undici's ownfetch.Filed via GitHub Discussions (issues are disabled on this repo).
All reactions