-
- Notifications
You must be signed in to change notification settings - Fork 728
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
When a WebSocket connection is closed due to an error, the close event doesn't get emitted.
Reproducible By
Run this in Node.js REPL (assumes undici is installed):
const { WebSocket } = require('undici') let ws = new WebSocket('wss://example.com/non-existing-url') ws.onerror = () => console.log('ERROR!') ws.onclose = () => console.log('CLOSE!')Expected Behavior
The WebSocket instance must dispatch two events in the following order:
ERROR! CLOSE! Actual behavior
It doesn't. Only the error event gets dispatched. The close event never gets dispatched, which I believe to be incorrect.
ERROR! Logs & Screenshots
I can also verify that the browser implementation of WebSocket behaves correctly:
Environment
I believe the environment is irrelevant here.
- undici 6.6.2
Additional context
The
errorevent is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent for example).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
