Skip to content

Allow use of builtin node WebSocket when available#26682

Open
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:WebSocket_node
Open

Allow use of builtin node WebSocket when available#26682
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:WebSocket_node

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Apr 14, 2026

Node v21 and up have native WebSocket support. This change makes the import of the external ws module conditional so it will only run on older versions of node.

See #26676

@sbc100 sbc100 requested a review from kripken April 14, 2026 19:05
@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Apr 14, 2026

@jeroen

@sbc100 sbc100 changed the title Allow use of builtin node WebSocket when available. NFS Allow use of builtin node WebSocket when available Apr 14, 2026
Node v21 and up have native WebSocket support.  This change makes the
import of the external `ws` module conditional so it will only run on
older versions of node.

See emscripten-core#26676
@jeroen
Copy link
Copy Markdown

jeroen commented Apr 14, 2026

Actually Claude suggests we also need to update the event handlers, see the second half of changes in libsockfs.js here: https://github.com/jeroen/emscripten/pull/1/changes

Because peer.socket.on('open', handleOpen) only applies to the ws implementation we no longer condition that on if (ENVIRONMENT_IS_NODE) but instead on if (typeof peer.socket.on === 'function') .

@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Apr 14, 2026

Actually Claude suggests we also need to update the event handlers, see the second half of changes in libsockfs.js here: https://github.com/jeroen/emscripten/pull/1/changes

Because peer.socket.on('open', handleOpen) only applies to the ws implementation we no longer condition that on if (ENVIRONMENT_IS_NODE) but instead on if (typeof peer.socket.on === 'function') .

Good point. I decided to cleanup that code a bit first: #26683

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