Skip to content

fix: websocket check to prevent runtime conflict on network framework#60

Merged
DjDeveloperr merged 2 commits into
mainfrom
fix/websocket-check
May 22, 2026
Merged

fix: websocket check to prevent runtime conflict on network framework#60
DjDeveloperr merged 2 commits into
mainfrom
fix/websocket-check

Conversation

@NathanWalker
Copy link
Copy Markdown
Collaborator

@NathanWalker NathanWalker commented May 22, 2026

Browser-compatible WebSocket implementation in the createInspectorSocket function to prevent runtime errors when running in environments where a non-browser global WebSocket is present, such as NativeScript on iOS. The main change is the introduction of a stricter check for a browser-style WebSocket before attempting to instantiate it.

WebSocket environment detection improvements:

  • Replaced the previous typeof WebSocket === "function" check with a new isBrowserWebSocket function in index.ts to ensure the global WebSocket is compatible with browser APIs before using it. This prevents instantiation errors with native classes that are not true WebSocket polyfills.
  • Added the isBrowserWebSocket helper function, which checks for browser-style readyState constants (CONNECTING, OPEN) and the presence of send and close methods on the prototype, ensuring only real browser WebSocket polyfills are used.

@DjDeveloperr DjDeveloperr merged commit 11db9b5 into main May 22, 2026
7 checks passed
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.

2 participants