Skip to content

Conversation

KhafraDev
Copy link
Member

Fixes #4081

This might be a breaking change? undici:websocket:open is now published after the open event is emitted (similar to the current close channel behavior), before it was published before. Also in the opening event, extensions and protocol are now equivalent to their WebSocket.prototype versions, which means that they are now '' instead of null when empty.

@KhafraDev
Copy link
Member Author

If it is a semver-major change, I'll throw in the changes to socket_error too. I was hoping it wouldn't be breaking, but looking at it now it probably is.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it breaking? The object only had an additive change. Is there a major change in behavior?

@KhafraDev
Copy link
Member Author

KhafraDev commented Jul 7, 2025

extensions and protocol were both already in the opening channel, but now when not present, they will be an empty string rather than null. It does also change the order of when the opening event is fired, but this isn't as important, but still potentially noticeable if you had something along the lines of:

const events = []
const ws = new WebSocket('ws://localhost')

diagnosticsChannel.subscribe('undici:websocket:open', () => events.push('dc open'))
ws.addEventListener('open', () => events.push('ws open'))

console.log(events) 
// before: ['dc open', 'ws open']
// after: ['ws open', 'dc open']

@mcollina
Copy link
Member

I'd say we ship and revert if we broke anyone.

@KhafraDev KhafraDev merged commit 5c904dd into nodejs:main Jul 17, 2025
29 checks passed
@github-actions github-actions bot mentioned this pull request Jul 18, 2025
@JoshMock JoshMock mentioned this pull request Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocket diagnostic channels lack request identities
2 participants