Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globalThis.Websocket usage in node > 22.4.0 #56

Open
tschellenbach opened this issue Oct 26, 2024 · 3 comments
Open

globalThis.Websocket usage in node > 22.4.0 #56

tschellenbach opened this issue Oct 26, 2024 · 3 comments

Comments

@tschellenbach
Copy link

See https://nodejs.org/api/globals.html#websocket

image

The if statement in api.js globalThis.WebSocket doesn't work as intended in recent node versions.

@halilxibrahim
Copy link

If I am not mistaken,It seems that the globalThis.WebSocket reference isn’t functioning as expected in Node.js version 22.4.0 and later. This issue might be due to changes in how Node handles globalThis.WebSocket.
Conditional Loading of WebSocket: If globalThis.WebSocket is undefined, we can manually require the WebSocket module:
if (typeof globalThis.WebSocket === 'undefined') { globalThis.WebSocket = require('ws'); }

  • Check for Updates or If globalThis.WebSocket continues to behave unexpectedly, consider using an alternative library or directly relying on the ws package for establishing WebSocket connections.

@the-wc
Copy link

the-wc commented Oct 28, 2024

Had this issue with v22.2.0 too. Ended up downgrading for the demo.

@NoRKin
Copy link

NoRKin commented Oct 31, 2024

Same issue in bun & deno

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

No branches or pull requests

4 participants