Skip to content

fix: normalize HTTP/2 headers for legacy dispatch handlers - #5867

Merged
mcollina merged 1 commit into
nodejs:mainfrom
Knowzzz:fix-legacy-http2-raw-headers
Sep 24, 2026
Merged

mcollina merged 1 commit into
nodejs:mainfrom
Knowzzz:fix-legacy-http2-raw-headers

Conversation

@Knowzzz

@Knowzzz Knowzzz commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This relates to...

Fixes #5865. Supersedes #5866 after renaming the source branch.

Rebased onto main at 8145595. Main has since reverted #5811 in #5860; this PR preserves that revert, including the HTTP/1.1 restriction for legacy dispatcher consumers and the native-fetch redirect regression test.

Rationale

HTTP/2 controllers expose rawHeaders / rawTrailers as objects, whereas legacy dispatch callbacks require raw arrays. LegacyHandlerWrapper currently forwards non-null object values unchanged.

The normalization remains necessary when Dispatcher1Wrapper.wrapHandler() is used directly with an HTTP/2-capable dispatcher. This PR does not re-enable HTTP/2 for legacy global fetch.

Changes

  • Preserve existing HTTP/1.1 raw arrays without copying them.
  • Convert HTTP/2 header/trailer objects with the existing toRawHeaders helper before calling legacy onHeaders, onComplete, or onUpgrade.
  • Preserve main's allowH2: false dispatch guard and native-fetch redirect/WebSocket behavior.
  • Keep the upstream deletion of the HTTP/2-only native-fetch fixture.
  • Exercise the handler bridge directly against real TLS servers: HTTP/1.1 and HTTP/2 headers/trailers, Latin-1 values, repeated Set-Cookie, and HTTP/2 CONNECT headers.

No public API or type changes.

Validation

Node.js 22.23.2 and 24.20.0, Linux x86_64:

npm ci --ignore-scripts --no-audit --no-fund
npm run generate-pem
node --test --test-timeout=15000 \
  test/dispatcher1-http2-headers.js \
  test/node-test/global-dispatcher-version.js \
  test/dispatcher.js \
  test/websocket/issue-4989.js
# Each Node version: 11 passed, 1 skipped (existing Node-26-only test)

npx eslint lib/dispatcher/dispatcher1-wrapper.js \
  test/dispatcher1-http2-headers.js \
  test/node-test/global-dispatcher-version.js
# passed (Node 24)
git diff --check upstream/main
# passed

The first run before generating the PEM fixtures failed TLS handshakes; after the repository's certificate-generation step, both Node versions passed. The full test suite has not been run. No typechecks.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested (targeted coverage above)
  • Benchmarked (optional)
  • Documented
  • Review ready
  • In review
  • Merge ready

@mcollina

Copy link
Copy Markdown
Member

There are conflicts now, unfortunatelyt.

Signed-off-by: Knowzzz <sacha.delpom@gmail.com>
@Knowzzz
Knowzzz force-pushed the fix-legacy-http2-raw-headers branch from 8da31d1 to 40736a3 Compare September 23, 2026 14:36
@Knowzzz

Knowzzz commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up @mcollina! Rebased on latest main and resolved the conflicts. The revert from #5860 is preserved, and the targeted tests pass on Node 22 and 24.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.89%. Comparing base (8145595) to head (40736a3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5867      +/-   ##
==========================================
- Coverage   93.90%   93.89%   -0.01%     
==========================================
  Files         110      110              
  Lines       39901    39907       +6     
==========================================
+ Hits        37470    37472       +2     
- Misses       2431     2435       +4     

☔ 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.

@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.

lgtm

@mcollina
mcollina merged commit 5e6e0e9 into nodejs:main Sep 24, 2026
36 of 38 checks passed
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.

8.11.0: native Node fetch loses HTTP/2 headers and fails to decode compressed responses

4 participants