fix(websocket): fallback to HTTP/1.1 when H2 CONNECT is unavailable#4966
Merged
fix(websocket): fallback to HTTP/1.1 when H2 CONNECT is unavailable#4966
Conversation
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4966 +/- ##
=======================================
Coverage 92.95% 92.96%
=======================================
Files 111 111
Lines 35821 35864 +43
=======================================
+ Hits 33299 33342 +43
Misses 2522 2522 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina
commented
Apr 3, 2026
| await planner.completed | ||
| }) | ||
|
|
||
| test('WebSocket falls back to HTTP/1.1 upgrade when H2 extended CONNECT is unavailable', async (t) => { |
Signed-off-by: Matteo Collina <hello@matteocollina.com>
ronag
approved these changes
Apr 3, 2026
pimterry
approved these changes
Apr 3, 2026
Member
pimterry
left a comment
There was a problem hiding this comment.
I'm not super familiar with the Undici internals, but they look roughly sensible to me - the test definitely looks like the right end behaviour 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix websocket handshakes when TLS negotiates HTTP/2 but the server does not advertise RFC 8441 extended CONNECT support.
Instead of failing immediately, retry the opening handshake on a fresh HTTP/1.1-only connection. This preserves websocket support for
allowHTTP1HTTP/2 servers and other deployments that only support websocket upgrade over HTTP/1.1.Changes
Agentand proxy TLS connectorsTesting
npx eslint lib/dispatcher/client.js lib/dispatcher/proxy-agent.js lib/dispatcher/agent.js lib/web/fetch/index.js test/websocket/opening-handshake.jsnode --test test/websocket/opening-handshake.js