Skip to content

fix(milo): port llhttp fixes and run CI with Milo - #6206

Open
mcollina wants to merge 3 commits into
fix/milo-idle-socket-validationfrom
fix/milo-parity-ci
Open

mcollina wants to merge 3 commits into
fix/milo-idle-socket-validationfrom
fix/milo-parity-ci

Conversation

@mcollina

@mcollina mcollina commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Stacked on #6205: this PR targets its branch, so the diff shows only the changes here, and it will move to main once #6205 lands. With Milo, test/interceptors/dns.js fails on main because of the missing idle socket validation that #6205 adds.

CI never ran the test suite with the experimental Milo parser enabled, so fixes made to the llhttp path did not reach Milo, and nothing reported it. I ran every test file of the suites CI runs (434 files) with UNDICI_USE_MILO=1 on main: 5 files fail, and test/client.js hangs the run. jest and the cache tests pass. This PR fixes the gaps in undici's Milo integration, skips the cases that Milo rejects by design, and adds a CI job that runs the suite with Milo.

Fixes in lib/dispatcher/parser-h1.js

  • Socket end while paused (port of fix(h1): complete paused parser on socket end instead of crashing #5474). finish() now resumes a parser paused by backpressure, completes a body whose completion was deferred, and parses what is still buffered before signalling EOF. Before, a complete Content-Length response paused by backpressure failed with Invalid EOF state (test/client.js), and the failed test left the process running.
  • 304 with Content-Length (port of fix(http1): fix handling of 204/304 responses #5864). A 304 with a non-zero Content-Length is delivered without a body and the connection is not reused, instead of failing with ResponseContentLengthMismatchError (test/content-length.js).
  • Upgrades (port of fix: complete upgrade diagnostics lifecycle #5761). onRequestUpgrade receives statusText, so the diagnostics headers event reports Switching Protocols. When the upgrade handler throws, the request is now errored, as with llhttp. Before, Milo only destroyed the socket, which the request no longer owned, so the request never received a terminal event (test/node-test/diagnostics-channel/upgrade.js).

Skipped with Milo

Milo's parser rejects a 204 with Content-Length, even Content-Length: 0, and a 204 or 304 with Transfer-Encoding (RFC 9110 §8.6, RFC 9112 §6.1). llhttp accepts these responses and closes the connection when they declare content (#5864, #5941). The 9 tests in test/content-length.js that expect this are skipped with Milo until Milo accepts these responses; see ShogunPanda/milo#63.

test/issue-4389.js already skipped its HTTP/1.0 test for Milo, but only when UNDICI_USE_MILO was 'true'; the parser also accepts '1'. The new test/utils/milo.js helper uses the parser's own getMiloEnabled().

CI

  • nodejs.yml gains a milo input, passed to every test step as UNDICI_USE_MILO, like no-wasm-simd.
  • ci.yml gains test-with-milo, on ubuntu-latest for Node.js 22, 24, 25 and 26, the same matrix as the WASM SIMD job. Automerge waits for it.

Testing

  • All 434 test files of the suites CI runs, each in its own process with UNDICI_USE_MILO=1: all pass. 10 tests are skipped with Milo: the 9 above, plus the HTTP/1.0 test in test/issue-4389.js.
  • jest and the cache tests pass with Milo.
  • With llhttp, the changed test files pass with no skips.
  • I did not run WPT with Milo locally: my WPT checkout is not the commit this branch pins. The new CI job runs it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sfj4nEWQ4ovycNDjbvXcRs

mcollina and others added 2 commits November 13, 2026 12:01
Fixes made to the llhttp path did not reach the experimental Milo
parser, and CI did not run the tests with Milo enabled:

- On socket end, finish() now resumes a parser paused by backpressure,
  completes a body whose completion was deferred, and parses what is
  still buffered before signalling EOF, as llhttp does since #5474.
  Before, a complete response paused by backpressure failed with
  'Invalid EOF state'.
- A 204/304 with a non-zero Content-Length is delivered without a body
  and the connection is not reused, as llhttp does since #5864, instead
  of failing with ResponseContentLengthMismatchError.
- Upgrades pass statusText to onRequestUpgrade, and an upgrade handler
  error now errors the request, as llhttp does since #5761, instead of
  only destroying the socket and leaving the request without a terminal
  event.

Milo itself rejects Content-Length on 204 responses and
Transfer-Encoding on 204/304 responses (RFC 9110 section 8.6, RFC 9112
section 6.1). Skip the tests that expect llhttp's lenient handling when
Milo is enabled, using a helper that reads UNDICI_USE_MILO the way the
parser does. test/issue-4389.js checked only for 'true' and ran its
HTTP/1.0 test with UNDICI_USE_MILO=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sfj4nEWQ4ovycNDjbvXcRs
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Add a milo input to the reusable Node.js workflow, passed to every test
step as UNDICI_USE_MILO, and a test-with-milo job that runs the suite
with Milo on ubuntu-latest for every tested Node.js version, like the
WASM SIMD job. Automerge waits for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sfj4nEWQ4ovycNDjbvXcRs
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter

codecov-commenter commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.72549% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.68%. Comparing base (c7e9976) to head (4db6845).

Files with missing lines Patch % Lines
lib/dispatcher/parser-h1.js 13.72% 44 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##           fix/milo-idle-socket-validation    #6206      +/-   ##
===================================================================
- Coverage                            91.76%   91.68%   -0.09%     
===================================================================
  Files                                  113      113              
  Lines                                44457    44506      +49     
===================================================================
+ Hits                                 40797    40804       +7     
- Misses                                3660     3702      +42     

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sfj4nEWQ4ovycNDjbvXcRs
Signed-off-by: Matteo Collina <hello@matteocollina.com>

This branch has not been deployed

No deployments
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