Fix jsdom 28 WebSocket cross-realm Event incompatibility#1161
Open
Copilot wants to merge 5 commits intodependabot/npm_and_yarn/jsdom-28.1.0from
Open
Fix jsdom 28 WebSocket cross-realm Event incompatibility#1161Copilot wants to merge 5 commits intodependabot/npm_and_yarn/jsdom-28.1.0from
Copilot wants to merge 5 commits intodependabot/npm_and_yarn/jsdom-28.1.0from
Conversation
Co-authored-by: MatthijsBurgh <18014833+MatthijsBurgh@users.noreply.github.com>
Add detection for jsdom environment in WebSocketTransportFactory to prevent using jsdom's native WebSocket which has cross-realm Event issues. This forces the use of the ws package in jsdom environments, avoiding the ERR_INVALID_ARG_TYPE error when dispatching events. Co-authored-by: MatthijsBurgh <18014833+MatthijsBurgh@users.noreply.github.com>
Update transport test to expect WsWebSocketTransport in jsdom environments, as the fix intentionally uses ws package instead of native WebSocket to avoid cross-realm Event issues. Co-authored-by: MatthijsBurgh <18014833+MatthijsBurgh@users.noreply.github.com>
Enhanced jsdom environment detection with multiple checks: - Try-catch for navigator.userAgent check (avoids circular lint rules) - Window constructor name check - jsdom-specific Symbol check in globalThis Also simplified test name per code review feedback. Co-authored-by: MatthijsBurgh <18014833+MatthijsBurgh@users.noreply.github.com>
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Bump jsdom from 27.4.0 to 28.1.0
Fix jsdom 28 WebSocket cross-realm Event incompatibility
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jsdom 28 creates Event objects in an isolated realm, causing Node.js's native WebSocket to fail validation with
TypeError: The "event" argument must be an instance of Event. Received an instance of Event.Changes
WebSocketTransportFactory: Added jsdom environment detection to force
wspackage usage instead of native WebSockettransport.test.ts: Updated expectations to reflect WsWebSocketTransport usage in jsdom environments
Technical Context
jsdom 28's improved prototype chain isolation means:
Real browsers unaffected - detection is specific to jsdom's implementation details.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.