Skip to content

Remove legacy handler wrappers - #4786

Merged
mcollina merged 16 commits into
nextfrom
plan/remove-wraphandler
Feb 7, 2026
Merged

mcollina merged 16 commits into
nextfrom
plan/remove-wraphandler

Conversation

@mcollina

Copy link
Copy Markdown
Member

Summary

  • fix raw header handling in cache/decompress interceptors
  • add shared toRawHeaders utility
  • update snapshot replay raw headers
  • bulk of the v8 version change

Testing

  • npm test

@mcollina

Copy link
Copy Markdown
Member Author

I used AI for this, so review with caution

@codecov-commenter

codecov-commenter commented Jan 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.01312% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.25%. Comparing base (4b36fef) to head (653d513).
⚠️ Report is 116 commits behind head on next.

Files with missing lines Patch % Lines
lib/interceptor/cache.js 73.33% 8 Missing ⚠️
lib/interceptor/decompress.js 74.07% 7 Missing ⚠️
lib/mock/snapshot-agent.js 85.71% 2 Missing ⚠️
lib/mock/mock-utils.js 95.23% 1 Missing ⚠️
lib/web/fetch/index.js 95.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #4786   +/-   ##
=======================================
  Coverage   93.25%   93.25%           
=======================================
  Files         109      107    -2     
  Lines       34001    34031   +30     
=======================================
+ Hits        31708    31736   +28     
- Misses       2293     2295    +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 added the semver-major Features or fixes that will be included in the next semver major release label Jan 31, 2026
BREAKING CHANGE: Node.js 20 is no longer supported. Minimum Node.js version is now 22.

Changes:
- Update engines field in package.json to >=22.0.0
- Remove Node 20 from CI test matrix
- Add Node 22 to WASM SIMD disabled test matrix
- Simplify cache-interceptor test to always use sqlite
- Update @types/node to ^22.0.0
@hexchain

hexchain commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

This should also fix #4389.

@mcollina
mcollina merged commit 393094a into next Feb 7, 2026
31 checks passed
@domenic

domenic commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Let me know if it would be helpful to test the next branch in jsdom, and if so, when a good point for that would be. (Presumably not right now since it's 18 commits behind main, but perhaps as you get closer to release.)

@mcollina

mcollina commented Feb 8, 2026

Copy link
Copy Markdown
Member Author

I'll ship an alpha soon.

@mcollina mcollina mentioned this pull request Mar 14, 2026
This was referenced Apr 2, 2026
sethbacon added a commit to sethbacon/terraform-drift-report that referenced this pull request Aug 15, 2026
#60)

Dependabot offered undici 8.10.0 (the first offer since the duplicated
override was fixed in #52). It does not work here, and the failure is a
runtime one that only the real-handshake tests catch.

This action hands a userland undici Agent/ProxyAgent to Node's BUILT-IN
global fetch as init.dispatcher, so two copies of undici meet on every
request that configures TLS trust or an egress proxy: ours, and the one
compiled into the runner's Node. They have to agree on the dispatcher
handler interface.

undici 8.0.0 deleted the wrap-handler shim that bridged the legacy
interface (nodejs/undici#4786), so assertRequestHandler now hard-requires
onRequestStart/onResponseStart/onResponseData/onResponseEnd. Node 24
bundles undici 7.21.0, whose fetch still builds the LEGACY handler, hands
it to our dispatcher, and undici 8 rejects it:

  InvalidArgumentError: invalid onRequestStart method (UND_ERR_INVALID_ARG)

Every proxied callback and every private-CA callback fails. On 8.10.0
that is 6 unit tests and 21 of 56 dist checks; the plain public-CA,
no-proxy path still works, which is exactly why this needed the positive
controls rather than the release notes.

undici 7 accepts both handler shapes, so 7.29.0 is a drop-in: the Agent
and ProxyAgent constructors, `connect: { ca }`, `requestTls: { ca }` and
proxy URI credentials are all unchanged from 6.x. Full suite green in
both source and dist.

The dependabot ignore records the rule rather than the symptom — the
userland undici major must not get ahead of the major the runner's Node
has built in — and says how to check when it can be lifted.

Bundle grows 445 KB -> 554 KB (index.js); the metafile attributes
108,747 of the 108,726-byte delta to undici itself, which is simply a
bigger library in 7.x.
sethbacon added a commit to sethbacon/terraform-module-publish that referenced this pull request Aug 15, 2026
#63)

Dependabot offered undici 8.10.0 (the first offer since the duplicated
override was fixed). It does not work here, and the failure is a runtime
one that only the real-handshake tests catch.

This action hands a userland undici Agent/ProxyAgent to Node's BUILT-IN
global fetch as init.dispatcher, so two copies of undici meet on every
request that configures TLS trust or an egress proxy: ours, and the one
compiled into the runner's Node. They have to agree on the dispatcher
handler interface.

undici 8.0.0 deleted the wrap-handler shim that bridged the legacy
interface (nodejs/undici#4786), so assertRequestHandler now hard-requires
onRequestStart/onResponseStart/onResponseData/onResponseEnd. Node 24
bundles undici 7.21.0, whose fetch still builds the LEGACY handler, hands
it to our dispatcher, and undici 8 rejects it:

  InvalidArgumentError: invalid onRequestStart method (UND_ERR_INVALID_ARG)

Every proxied registry call and every private-CA registry call fails. On
8.10.0 that is 6 unit tests; the plain public-CA, no-proxy path still
works, which is exactly why this needed the positive controls rather than
the release notes.

undici 7 accepts both handler shapes, so 7.29.0 is a drop-in: the Agent
and ProxyAgent constructors, `connect: { ca }`, `requestTls: { ca }` and
proxy URI credentials are all unchanged from 6.x. Full suite green in
both source (235 tests) and dist (92 checks).

The dependabot ignore records the rule rather than the symptom — the
userland undici major must not get ahead of the major the runner's Node
has built in — and says how to check when it can be lifted.

Bundle grows 450 KB -> 558 KB; the whole 108,740-byte delta is undici
itself, which is simply a bigger library in 7.x.
mcollina pushed a commit that referenced this pull request Aug 31, 2026
/xhr was dropped from the test:wpt filter in #4786 without mention in
the PR, which removed WPT FormData coverage: that suite lives under
/xhr/formdata rather than /fetch. Restore the filter and record the
xhr expectation entries for test files added to WPT since the removal.

Also drop /serviceWorkers from the filter: the WPT directory is
service-workers, so the argument has never matched any test.
mgcronin added a commit to openzigs/metis that referenced this pull request Sep 27, 2026
…314)

* fix: [Issue #308] upgrade undici to 8 and wrap every dispatcher for the built-in fetch

undici 8 removed its legacy-handler shim (nodejs/undici#4786). Node 22's
built-in fetch still hands dispatchers a legacy handler, so every undici 8
Agent/ProxyAgent passed as `dispatcher` to globalThis.fetch failed with
"invalid onRequestStart method". CI caught this only in the local-provider
transport. The pinned-SSRF, webhook, importer and proxy sites broke the same
way, but their tests use fake dispatchers.

All dispatcher construction now goes through
server/src/lib/net/builtin-fetch-dispatcher.ts, which wraps each dispatcher in
Dispatcher1Wrapper as the v7->v8 migration guide says. The wrapper also keeps
HTTP/1.1, where v7 already was. A source scan fails if a dispatcher is built
anywhere else. New real-loopback tests cover the headers/body timeouts, abort,
streaming, the FIFO limiter and the proxies through the built-in fetch.

The Node floor rises to 22.19.0 (undici 8 engines), and the dev compose image
moves from Node 20 to Node 22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011jaVZMaMEggfWYuKsCKudr

* test: [Issue #308] test forward proxies relay to one fixed destination

CodeQL flagged the loopback test proxies as request forgery, because they
forwarded to the request-line URL. They now accept only the one test target
and relay to a fixed host and port. The tests assert the exact absolute-form
request line, so a request that bypasses the proxy fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011jaVZMaMEggfWYuKsCKudr

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-major Features or fixes that will be included in the next semver major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants