Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/node-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ interface ProxyConfig {
let installed = false;
const directDispatcher = new Agent();
const proxyDispatcherCache = new Map<string, Dispatcher>();
const nativeFetch = globalThis.fetch.bind(globalThis);
const nativeFetch = globalThis.fetch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be simpler to make nativeFetch a tiny wrapper instead of choosing once at module load? As written, if fetch is missing during import but gets installed later, the direct path is still pinned to undiciFetch for the rest of the process.

? globalThis.fetch.bind(globalThis)
: (input, init) => undiciFetch(input, init);

function readEnv(env: NodeJS.ProcessEnv, lower: string, upper: string): string | undefined {
const lowerValue = env[lower];
Expand Down