-
-
Notifications
You must be signed in to change notification settings - Fork 675
Description
Bug Description
The new WebSocket library is pretty great, but when a WebSocket connection closes without completing the control frame exchange, it spits out an empty message TypeError, which isn't very descriptive of the problem and appears as an error message that accidentally slipped through the deployment. The exact line of code is:
undici/lib/web/websocket/websocket.js
Lines 589 to 591 in dc5802d
| fireEvent('error', this, (type, init) => new ErrorEvent(type, init), { | |
| error: new TypeError(reason) | |
| }) |
Reproducible By
Haven't written exact steps to reproduce, but it happens occasionally on connection closure.
Expected Behavior
Perhaps a better description of the connection closure in the ErrorEvent? "Connection closed with code: xyz"
Also imo, would be better to use a plain Error rather than a TypeError.
If this is something the team feels would be a good addition, happy to make a PR
Logs & Screenshots
TypeError\n at #onSocketClose (node:internal/deps/undici/undici:13908:20)\n at TLSSocket.onSocketClose (node:internal/deps/undici/undici:13611:72)\n at TLSSocket.emit (node:events:520:35)\n at node:net:346:12\n at TCP.done (node:_tls_wrap:649:7)
Environment
Ubuntu 20, NodeJS 24.0