fix(coding-agent): remove global fetch override closes #4619

This commit is contained in:
Mario Zechner
2026-05-17 20:51:26 +02:00
parent 6f931797ca
commit c9e7049212
11 changed files with 40 additions and 27 deletions

View File

@@ -5,7 +5,7 @@
*
* Test with: npx tsx src/cli-new.ts [args...]
*/
import { EnvHttpProxyAgent, setGlobalDispatcher, fetch as undiciFetch } from "undici";
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
import { APP_NAME } from "./config.js";
import { main } from "./main.js";
@@ -17,15 +17,6 @@ process.emitWarning = (() => {}) as typeof process.emitWarning;
// (e.g. vLLM buffering a large tool call) exceed that and abort the SSE stream
// with UND_ERR_BODY_TIMEOUT. Disable both — provider SDKs enforce their own
// AbortController-based deadlines via retry.provider.timeoutMs.
// Node 26 uses an internal undici for globalThis.fetch that does not honor npm
// undici's global dispatcher, so route global fetch through npm undici as well.
const dispatcher = new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 });
setGlobalDispatcher(dispatcher);
const fetchWithDispatcher = undiciFetch as unknown as typeof fetch;
globalThis.fetch = (input, init) =>
fetchWithDispatcher(input, {
...init,
dispatcher,
} as unknown as RequestInit);
setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
main(process.argv.slice(2));