Skip to content

fix: preserve raw headers in dispatch handler bridge#5345

Merged
mcollina merged 1 commit into
v7.xfrom
fix/5341-legacy-raw-headers
Jun 3, 2026
Merged

fix: preserve raw headers in dispatch handler bridge#5345
mcollina merged 1 commit into
v7.xfrom
fix/5341-legacy-raw-headers

Conversation

@mcollina

@mcollina mcollina commented Jun 3, 2026

Copy link
Copy Markdown
Member

Description

Preserve rawHeaders and rawTrailers on the synthetic controller used by UnwrapHandler when bridging modern dispatch handlers to the legacy handler interface.

This keeps Node.js bundled fetch compatible with an imported Undici v7 Agent, so response headers remain visible and compressed bodies continue to be decoded.

Fixes: #5341

Changes

  • store rawHeaders on the controller before invoking onRequestUpgrade / onResponseStart
  • store rawTrailers before invoking onResponseEnd
  • expose the optional controller fields in types/dispatcher.d.ts
  • add a regression test covering Node.js global fetch with both the global dispatcher and an explicit dispatcher: new Agent()

Testing

  • npm run lint -- lib/handler/unwrap-handler.js test/node-test/global-dispatcher-version.js types/dispatcher.d.ts
  • npx borp -p "test/node-test/global-dispatcher-version.js"
  • source ~/.nvm/nvm.sh && nvm use 26.3.0 >/dev/null && npx borp -p "test/node-test/global-dispatcher-version.js"

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.90%. Comparing base (d7aeee3) to head (7ecea4c).

Additional details and impacted files
@@            Coverage Diff             @@
##             v7.x    #5345      +/-   ##
==========================================
- Coverage   92.91%   92.90%   -0.01%     
==========================================
  Files         112      112              
  Lines       35837    35843       +6     
==========================================
+ Hits        33297    33299       +2     
- Misses       2540     2544       +4     

☔ 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 3e17d92 into v7.x Jun 3, 2026
68 of 70 checks passed
@mcollina mcollina deleted the fix/5341-legacy-raw-headers branch June 3, 2026 11:53
@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
QuiiBz added a commit to vercel/sandbox that referenced this pull request Jun 4, 2026
Closes #198

Update the Undici version we use to fix an issue where using Undici v7
`Agent` with a Undici v8 `fetch` (e.g. using Node.js 26 with the global,
bundled `fetch`) would cause response headers to be dropped, and
response body to not be decompressed

Upstream Undici fix: nodejs/undici#5345
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.

4 participants