-
Notifications
You must be signed in to change notification settings - Fork 45
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
Bug: WS connection does not work using node 22 #255
Comments
I have the same issue. This is likely not a bug in surrealdb.js, but rather a bug in undici or a non-compliance with the WebSocket specification (RFC 6455) by other WebSocket clients. The WebSocket class, which was added to the global namespace without a flag in Node.js v22, is implemented within undici and seems to behave slightly differently from other WebSocket clients (Deno and ws). Specifically, there is a discrepancy in how chunked data sent from the WebSocket server is interpreted. undici does not reset the opcode unless chunked data containing a payload is sent. This means that when a ping response (<Buffer 89 00>) is received from the WebSocket server, undici remembers that the opcode is 9 (i.e. "Ping Frame") and ultimately drops the payload of subsequent chunked data. This ping communication is performed by the WebSocket to maintain the connection, independently of surrealdb.js's Pinger. To resolve this issue, it may be necessary to make changes to the implementation of undici. I'm using Node.js v22.1.0 and have checked the behavior with undici v6.13.0, but I have also obtained the same results with the latest version, v6.16.0. However, the WebSocket specification is quite complex, and I am not entirely sure if this is a bug in undici. It is also possible that undici's WebSocket implementation is correct and other implementations are not compliant with the specification. |
Hey everyone! I wasn't able to reproduce this issue last week, turns out that I was however able to reproduce it today, and it turns out that the I'm quite positive that this is an issue in NodeJS |
Hey everyone! I noticed that NodeJS a short while ago, merged in an autobahn test, so decided to give NodeJS 22 another shot. All seems well with NodeJS v22.3.0! |
Describe the bug
Node 22. When you try to connect to database with
ws://localhost:8000/rpc
- it throws an error.Node 20. Works as expected.
Steps to reproduce
Expected behaviour
Should return similar something like
SurrealDB version
1.4.2 for macos on aarch64
SurrealDB.js version
1.0.0-beta.5
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: