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

@@ -2,9 +2,15 @@
## [Unreleased]
### Breaking Changes
- Raised the minimum supported Node.js version to 22.19.0.
### Fixed
- Fixed user-scoped npm pi packages to install under `~/.pi/agent/npm/` instead of npm's global package root, avoiding permission errors with system-managed Node installs ([#4587](https://github.com/earendil-works/pi/issues/4587)).
- Fixed Mistral requests failing after the global fetch proxy/timeout workaround by removing the custom fetch override and using undici 8 dispatcher support instead ([#4619](https://github.com/earendil-works/pi/issues/4619)).
- Fixed default output token requests for models whose advertised output limit is effectively their full context window, avoiding impossible provider requests inherited from `@earendil-works/pi-ai` ([#4614](https://github.com/earendil-works/pi/issues/4614)).
## [0.74.1] - 2026-05-16

View File

@@ -52,7 +52,7 @@
"minimatch": "^10.2.3",
"proper-lockfile": "^4.1.2",
"typebox": "^1.1.24",
"undici": "^7.19.1",
"undici": "^8.3.0",
"yaml": "^2.8.2"
},
"overrides": {
@@ -90,6 +90,6 @@
"directory": "packages/coding-agent"
},
"engines": {
"node": ">=20.6.0"
"node": ">=22.19.0"
}
}

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));