Skip to content

fix: fallback to undiciFetch when globalThis.fetch is unavailable#840

Open
deep-innovator wants to merge 1 commit intojackwener:mainfrom
deep-innovator:patch-1
Open

fix: fallback to undiciFetch when globalThis.fetch is unavailable#840
deep-innovator wants to merge 1 commit intojackwener:mainfrom
deep-innovator:patch-1

Conversation

@deep-innovator
Copy link
Copy Markdown

Problem

On Windows with older Node.js versions, globalThis.fetch is not available at module load time, causing the original nativeFetch definition to fail immediately.

Solution

  • Keep nativeFetch as a direct request function, preserving the original signature (input, init) => Promise<Response>.
  • Fall back to undiciFetch synchronously when globalThis.fetch is unavailable.
  • This maintains the existing no-proxy path behavior while fixing the startup error on Windows.

Verification

  • No breaking changes to the call site return nativeFetch(input, init).
  • Works both with native fetch and the undiciFetch fallback.

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant