Skip to content

fix: preserve HTTP/2 for non-upgrade legacy requests - #5811

Open
mcollina wants to merge 1 commit into
mainfrom
fix/legacy-dispatcher-http2
Open

fix: preserve HTTP/2 for non-upgrade legacy requests#5811
mcollina wants to merge 1 commit into
mainfrom
fix/legacy-dispatcher-http2

Conversation

@mcollina

Copy link
Copy Markdown
Member

Summary

  • restrict the legacy dispatcher HTTP/1.1 compatibility override to upgrade requests
  • allow Node.js built-in fetch() to negotiate HTTP/2 through an Undici v8 global dispatcher
  • keep the native WebSocket fallback on HTTP/1.1 and assert its negotiated protocol
  • add an HTTP/2-only server regression fixture for built-in fetch()

Why

Dispatcher1Wrapper currently forces allowH2: false for every request. On Node.js versions whose built-in fetch consumes undici.globalDispatcher.1, this prevents a configured Undici v8 dispatcher from reaching servers that only advertise h2 through ALPN.

The override was introduced for legacy WebSocket consumers that cannot retry with HTTP/1.1 when HTTP/2 Extended CONNECT is unavailable. Scoping it to upgrade requests preserves that workaround without changing the protocol for ordinary fetch traffic.

Refs: #4989 and #4990.

Tests

  • npm run lint
  • npx borp -p "test/node-test/global-dispatcher-version.js" on Node.js 22.22.1, 24.18.1, and 26.8.1
  • npx borp -p "test/websocket/issue-4989.js" on Node.js 22.22.1, 24.18.1, and 26.8.1
  • npm run test:unit (one unrelated high-concurrency failure in test/issue-4880.js; isolated rerun passed)

@codecov-commenter

codecov-commenter commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.48%. Comparing base (cb7373a) to head (584ca8b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5811      +/-   ##
==========================================
- Coverage   93.52%   93.48%   -0.05%     
==========================================
  Files         110      110              
  Lines       39415    39522     +107     
==========================================
+ Hits        36864    36947      +83     
- Misses       2551     2575      +24     

☔ View full report in Codecov by Harness.
📢 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.

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.

2 participants