mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-07-09 17:28:45 +00:00
fix(coding-agent): preserve fetch overrides
This commit is contained in:
parent
a78cd7ccb1
commit
a93f066607
1 changed files with 12 additions and 1 deletions
|
|
@ -10,6 +10,9 @@ export const HTTP_IDLE_TIMEOUT_CHOICES = [
|
|||
{ label: "disabled", timeoutMs: 0 },
|
||||
] as const;
|
||||
|
||||
const originalGlobalFetch = globalThis.fetch;
|
||||
let installedGlobalFetch: typeof globalThis.fetch | undefined;
|
||||
|
||||
export function parseHttpIdleTimeoutMs(value: unknown): number | undefined {
|
||||
if (typeof value === "string") {
|
||||
const trimmed = value.trim();
|
||||
|
|
@ -58,5 +61,13 @@ export function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TI
|
|||
// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's
|
||||
// bundled fetch can otherwise consume compressed responses through npm undici's
|
||||
// dispatcher without decompressing them, causing response.json() failures.
|
||||
undici.install?.();
|
||||
// If a caller replaced fetch after module load, preserve that deliberate override.
|
||||
const shouldInstallGlobals =
|
||||
installedGlobalFetch === undefined
|
||||
? globalThis.fetch === originalGlobalFetch
|
||||
: globalThis.fetch === installedGlobalFetch;
|
||||
if (shouldInstallGlobals) {
|
||||
undici.install?.();
|
||||
installedGlobalFetch = globalThis.fetch;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue