From db643608192d2918d99a0c4b8b92a65aabf673de Mon Sep 17 00:00:00 2001 From: young_tree <63460237+deep-innovator@users.noreply.github.com> Date: Tue, 7 Apr 2026 08:38:40 +0800 Subject: [PATCH] fix: fallback to undiciFetch when globalThis.fetch is unavailable Resolves compatibility issue on Windows with older Node.js versions where `globalThis.fetch` is not available at module load time. This change keeps the original `nativeFetch` function signature unchanged, preserving the no-proxy path behavior while adding a synchronous fallback to `undiciFetch`. --- src/node-network.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node-network.ts b/src/node-network.ts index 49f216ee..d6e12d76 100644 --- a/src/node-network.ts +++ b/src/node-network.ts @@ -39,7 +39,9 @@ interface ProxyConfig { let installed = false; const directDispatcher = new Agent(); const proxyDispatcherCache = new Map(); -const nativeFetch = globalThis.fetch.bind(globalThis); +const nativeFetch = globalThis.fetch + ? globalThis.fetch.bind(globalThis) + : (input, init) => undiciFetch(input, init); function readEnv(env: NodeJS.ProcessEnv, lower: string, upper: string): string | undefined { const lowerValue = env[lower];