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

Add support for Node.js built-in WebSocket? #691

Open
thernstig opened this issue Nov 18, 2023 · 2 comments
Open

Add support for Node.js built-in WebSocket? #691

thernstig opened this issue Nov 18, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@thernstig
Copy link

thernstig commented Nov 18, 2023

Is your feature request related to a problem? Please describe.
I would like to decrease number of dependencies as it is a maintenance burden.

Describe the solution you'd like
Node.js 21 includes native WebSocket support under the --experimental-websocket. It would be nice if there was some kind of opt-in behavior to use it.

Describe alternatives you've considered
Keep using the ws socket.io dependency.

Additional context
I am not sure if this is even feasible. You'd need to install the ws package anyway for those running on Node <21. So it is possible this issue shall be closed immediately with "no action".

@thernstig thernstig added the enhancement New feature or request label Nov 18, 2023
@darrachequesne
Copy link
Member

Thanks for the heads-up! We could indeed use the new WebSocket client, though I'm not sure how we could conditionally import it and support both Node.js < 21 and Node.js > 21.

Source: https://github.com/socketio/engine.io-client/blob/main/lib/transports/websocket-constructor.ts

@thernstig
Copy link
Author

@darrachequesne maybe a bigger problem is if you support other platforms (Deno?) then it might be even more problematic?

Publishing different npm packages in your build pipeline would be one way, but maybe that is not wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants