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

20
package-lock.json generated
View file

@ -31,7 +31,7 @@
"typescript": "^5.9.2"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
}
},
"node_modules/@ampproject/remapping": {
@ -6842,12 +6842,12 @@
}
},
"node_modules/undici": {
"version": "7.25.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.25.0.tgz",
"integrity": "sha512-xXnp4kTyor2Zq+J1FfPI6Eq3ew5h6Vl0F/8d9XU5zZQf1tX9s2Su1/3PiMmUANFULpmksxkClamIZcaUqryHsQ==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-8.3.0.tgz",
"integrity": "sha512-TkUDgb6tl7KOGZ+7e8E3d2FYgUQgF6z5YypqjWmixVQSQERFcVrVg0ySADm2LVLRh5ljAaHTCR5Fmz3Q34rB7Q==",
"license": "MIT",
"engines": {
"node": ">=20.18.1"
"node": ">=22.19.0"
}
},
"node_modules/undici-types": {
@ -7787,7 +7787,7 @@
"vitest": "^3.2.4"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
}
},
"packages/agent/node_modules/@types/node": {
@ -7831,7 +7831,7 @@
"vitest": "^3.2.4"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
}
},
"packages/ai/node_modules/@types/node": {
@ -7870,7 +7870,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"
},
"bin": {
@ -7887,7 +7887,7 @@
"vitest": "^3.2.4"
},
"engines": {
"node": ">=20.6.0"
"node": ">=22.19.0"
},
"optionalDependencies": {
"@mariozechner/clipboard": "^0.3.6"
@ -7961,7 +7961,7 @@
"chalk": "^5.5.0"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
},
"optionalDependencies": {
"koffi": "^2.9.0"

View file

@ -45,7 +45,7 @@
"shx": "^0.4.0"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
},
"version": "0.0.3",
"dependencies": {

View file

@ -1,5 +1,11 @@
# Changelog
## [Unreleased]
### Breaking Changes
- Raised the minimum supported Node.js version to 22.19.0.
## [0.74.1] - 2026-05-16
## [0.74.0] - 2026-05-07

View file

@ -50,7 +50,7 @@
"directory": "packages/agent"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
},
"devDependencies": {
"@types/node": "^24.3.0",

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Breaking Changes
- Raised the minimum supported Node.js version to 22.19.0.
### Fixed
- Fixed `streamSimple()` defaults for models whose advertised output limit is effectively their full context window to avoid impossible default requests ([#4614](https://github.com/earendil-works/pi/issues/4614)).

View file

@ -97,7 +97,7 @@
"directory": "packages/ai"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
},
"devDependencies": {
"@types/node": "^24.3.0",

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

View file

@ -1,5 +1,11 @@
# Changelog
## [Unreleased]
### Breaking Changes
- Raised the minimum supported Node.js version to 22.19.0.
## [0.74.1] - 2026-05-16
### Added

View file

@ -32,7 +32,7 @@
"directory": "packages/tui"
},
"engines": {
"node": ">=20.0.0"
"node": ">=22.19.0"
},
"types": "./dist/index.d.ts",
"dependencies": {