Skip to content

Commit d852dc3

Browse files
abbaseyaclaude
andcommitted
fix(utils): tolerate null self in worker runtime detection
typeof null is 'object', so a mocked environment defining self = null passed the typeof guard and the importScripts access would throw. Optional chaining degrades it to undefined and falls through to the server checks, matching the file's existing navigator?.sendBeacon idiom. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7d47d87 commit d852dc3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/utils/src/http-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const determineRuntime = (): RuntimeResult => {
146146
// endpoint rejected, breaking every signals worker upload).
147147
if (
148148
typeof self !== 'undefined' &&
149-
typeof (self as {importScripts?: unknown}).importScripts === 'function'
149+
typeof (self as {importScripts?: unknown})?.importScripts === 'function'
150150
) {
151151
return {runtime: 'browser'};
152152
}

0 commit comments

Comments
 (0)