globalThis.Websocket usage in node > 22.4.0
Opened this issue · 3 comments
tschellenbach commented
See https://nodejs.org/api/globals.html#websocket
The if statement in api.js globalThis.WebSocket doesn't work as intended in recent node versions.
halilxibrahim commented
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 commented
Had this issue with v22.2.0 too. Ended up downgrading for the demo.
NoRKin commented
Same issue in bun & deno