Skip to content

add websocket to websocket diagnostic channels#4321

Merged
KhafraDev merged 1 commit into
nodejs:mainfrom
KhafraDev:websocket-dc-4081
Jul 17, 2025
Merged

add websocket to websocket diagnostic channels#4321
KhafraDev merged 1 commit into
nodejs:mainfrom
KhafraDev:websocket-dc-4081

Conversation

@KhafraDev

Copy link
Copy Markdown
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
Copy Markdown
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.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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

KhafraDev commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
slagiewka pushed a commit to slagiewka/undici that referenced this pull request Feb 14, 2026
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