Skip to content
Merged
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
14 changes: 14 additions & 0 deletions packages/utils/src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ const determineRuntime = (): RuntimeResult => {
return {runtime: 'browser'};
}

// Browser Web Workers have no `window` but are still browser runtimes.
// `importScripts` exists only in browser worker scopes — server runtimes
// (Node.js) and edge runtimes (e.g. Cloudflare Workers) do not expose it.
// Without this check a Web Worker falls through to 'server-with-fetch' and
// server-side-only behavior leaks into real browsers (the ConvertAgent
// User-Agent announcement below forced a CORS preflight the signals
// endpoint rejected, breaking every signals worker upload).
if (
typeof self !== 'undefined' &&
typeof (self as {importScripts?: unknown})?.importScripts === 'function'
) {
return {runtime: 'browser'};
}

// if window is not available, but fetch is, then we're on a server that has the fetch API available
if (typeof fetch === 'function') {
return {runtime: 'server-with-fetch'};
Expand Down
Loading