Skip to content

fix(websocket): support open diagnostics over h2#4921

Merged
mcollina merged 1 commit intomainfrom
fix/websocket-h2-diagnostics
Mar 21, 2026
Merged

fix(websocket): support open diagnostics over h2#4921
mcollina merged 1 commit intomainfrom
fix/websocket-h2-diagnostics

Conversation

@mcollina
Copy link
Member

Summary

Fix WebSocket open diagnostics for HTTP/2 connections.

WebSocket over HTTP/2 was already implemented, but subscribing to undici:websocket:open could crash the connection setup because the diagnostics payload assumed the transport always exposed socket.address(). Over HTTP/2 the transport is a stream, so the address needs to be resolved from the underlying session socket.

Changes

  • resolve websocket open diagnostic addresses for both HTTP/1.1 sockets and HTTP/2 streams
  • make websocket debug logging resilient when address information is unavailable
  • add HTTP/2 coverage for websocket handshake diagnostics
  • document HTTP/2 websocket handshake response semantics in diagnostics docs

Testing

  • npx eslint lib/web/websocket/websocket.js lib/core/diagnostics.js test/websocket/diagnostics-channel-handshake-response-h2.js
  • npm run test:websocket

@mcollina mcollina requested a review from KhafraDev March 21, 2026 11:02
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.91%. Comparing base (4c3a2be) to head (303c5fe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/core/diagnostics.js 0.00% 6 Missing ⚠️
lib/web/websocket/websocket.js 84.61% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4921   +/-   ##
=======================================
  Coverage   92.90%   92.91%           
=======================================
  Files         112      112           
  Lines       35646    35660   +14     
=======================================
+ Hits        33117    33133   +16     
+ Misses       2529     2527    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina merged commit 9766c6d into main Mar 21, 2026
38 checks passed
@mcollina mcollina deleted the fix/websocket-h2-diagnostics branch March 21, 2026 16:21
@github-actions github-actions bot mentioned this pull request Mar 24, 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.

3 participants