-
Notifications
You must be signed in to change notification settings - Fork 79
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
WebSocket client drops some incoming messages when running locally #983
Comments
On further investigation the problem occurs when the server sends a websocket ping message. See rnbrady/vercel-edge-runtime-983 to reproduce. |
I am unable to reproduce this bug in deployments to Vercel. To aid in testing I have deployed the |
This might be resolved by #546. |
Hello, this is going to be tricky to resolve since edge-runtime still supports Node.js v16, and to make this possible we are sticky to undici v5: https://github.com/vercel/edge-runtime/blob/main/packages/primitives/package.json#L33 The fix for the undici websocket version was shipped under undici v6, which is dropping Node.js v16 support. So in order to ship this we need to drop Node.js v16 support and upgrade (or drop) Undici , which is covered in #546 |
Thanks for the reply @Kikobeats. I'm happy to wait for #546. I just looked into how Cloudflare Workers does |
Bug Report
A WebSocket client instantiated in the Edge runtime will randomly drop incoming messages from the WedSocket server. In my test every 10th or so incoming message is dropped, but it probably depends on timing and message length (edit: it's actually triggered by a websocket keepalive).
Possible solution
This appears to be caused by by upstream bug nodejs/undici#2859 which has been fixed and released in nodejs/[email protected].
Bumping Undici from 5 to 6 appears to be a breaking change so Dependabot hasn't been able to do it automatically. Possibily complicating matters further is that Undici v6 does not support Node v16.
Additional context/screenshots
In my application I'm connecting from a server-side Edge function to a Bitcoin indexer over WebSocket to subscribe to balance updates which I then send to the client as server-sent events (SSE). After an initial handshake I ping the indexer over WebSocket every second, and the pongs are received except that every 10th or so one gets dropped and a null message is delivered:
With OpenAI recently annoucing their Realtime API based on WebSockets, other developers might soon run into this problem too.
tl;dr: please try and merge #947 🙏
The text was updated successfully, but these errors were encountered: