-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 native NodeJS WebSocket #10109
Comments
Related to #10042 discord.js/packages/util/src/functions/runtime.ts Lines 3 to 14 in 278396e
|
Oh nice! I didn't know about that one. Is it worth closing this issue then? |
Don't think so, it looks like the code still needs to be updated to support native WebSockets on Node, that PR focused on Deno and Bun support |
|
This is something I'll tackle sometime in the future. As it stands, the global ws is still experimental, and not as battle tested as Maybe after we see the Autobahn tests results for it, as well as some performance comparisons, we can add it in as the defacto implementation used for newer node versions. As it stands tho, if you really wanna try it out, you can fake that you're in bun/deno by setting that property in |
We now use default I think ideally, once discord.js is on a new enough node version (and there's no clear drawbacks), we move to full global WS regardless of env. For now, we could maybe investigate using global WS if available in node as well? |
I'd wanna see performance numbers and Autobahn results before even considering spending time investigating this 👁️ |
Performance - not measured yet. |
Which application or package is this feature request for?
discord.js
Feature
NodeJS will be enabling the
WebSocket
class by default in NodeJS 22: nodejs/node#51594 and is already available in NodeJS 21 as experimental. This would make the dependency onws
package optional or allow removing entirely.I will say that in my own usage of it, there are some discrepancies/missing properties between the ws package and the native, so I'm waiting for the @types/node update so that it is very clear what the differences are.
Ideal solution or implementation
Similar to how you can choose to use ffmpeg/avconv, tweetnacl/libsodium, etc. it would be nice to be able to use the
WebSocket
provided by node instead of a 3rd party version.Something like:
or just
Alternative solutions or implementations
No response
Other context
No response
The text was updated successfully, but these errors were encountered: