Repository navigation
fix: validate EOF for chunked h1 responses - #5273
Merged
Merged
Conversation
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5273 +/- ##
==========================================
- Coverage 93.28% 93.27% -0.01%
==========================================
Files 110 110
Lines 36384 36427 +43
==========================================
+ Hits 33939 33978 +39
- Misses 2445 2449 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Needs rebase to include node 26 FFI build from https://www,github.com/nodejs/undici/pull/5275 |
Member
Author
|
I think we can land without |
trivikr
approved these changes
May 10, 2026
Merged
This was referenced May 17, 2026
mcollina
added a commit
that referenced
this pull request
May 18, 2026
mcollina
added a commit
that referenced
this pull request
May 18, 2026
* fix: validate EOF for chunked h1 responses (#5273) (cherry picked from commit 13f6af6) Signed-off-by: Matteo Collina <hello@matteocollina.com> * test: restore websocket test compatibility on Node 18 - replace t.assert usage with node:assert in websocket tests so they work on Node 18\n- reduce the disabled-limit payload size in permessage-deflate-limit to avoid CI timeouts\n- remove an extra blank line in lib/dispatcher/agent.js to satisfy standard Signed-off-by: Matteo Collina <hello@matteocollina.com> --------- Signed-off-by: Matteo Collina <hello@matteocollina.com>
7 tasks done
clevengermatt
added a commit
to openbindings/sdk
that referenced
this pull request
Oct 24, 2026
* Require a Node whose fetch rejects a truncated chunked body On Node 22.19, TypeScript discover reported a chunked 200 body cut short as its connection closed as found or non-conformant, with the prefix attached. Node's bundled undici completed any response not kept alive when its socket ended, checking a fixed length but not chunked framing, so the stream simply ended. undici fixed this in nodejs/undici#5273, shipped as 6.26.0, 7.26.0 and 8.3.0. The first Node releases bundling a fixed undici are 22.23.0 (6.27.0), 24.17.0 (7.28.0) and 26.2.0 (8.3.0); 22.22.2, 24.16.0 and 26.1.0 bundle 6.24.1, 7.25.0 and 8.2.0, Node 23 ended on 6.21, and Node 25's last release bundles 7.24.4. Admit only fixed releases in engines (^22.23.0 || ^24.17.0 || >=26.2.0), state the floor and its reason where the docs give the Node version, pin CI to 22.23.0, and add a leg that runs the discovery tests, the ones that use the host's fetch, at the 24 and 26 floors against the package job's build. * Test that a truncated discovery body is a body error Serve each truncation shape from a raw local server: a chunked body without its terminating chunk, cut inside a chunk, cut across chunks, cut in the last chunk's size line, missing the final empty line, reset after its chunks, and a short fixed-length body, each with and without Connection: close, beside complete controls. Every truncated shape must be a body error with no body attached, through the host's own fetch. On the supported Node releases all 15 cases pass. On Node 22.19, whose bundled undici predates nodejs/undici#5273, the six chunked shapes under Connection: close fail. * Judge the pattern differential by the edition the dialect names JSON Schema 2020-12 core section 6.4 reads patterns in the dialect of ECMA-262 section 21.2.1, and its normative reference is the 11th edition (ES2020). The evaluator refuses syntax that edition lacks, but the TypeScript differential treated the running V8 as the oracle, so on Node 23 and 24, whose V8 accepts ES2025's modifiers such as (?i:a) and duplicate named groups, 14 of its 1,505 rows differed and the test failed. Keep the checked-in fixture, recorded on V8 12.4, as the oracle: an independent ES2020 pattern parser (regexpp, ecmaVersion 2020, unicode) accepts exactly the patterns it accepts, so no entry changes. Compare the live engine with it wherever a pattern uses only 11th edition syntax, which is 1,458 rows, and for the 47 rows holding modifiers (ES2025 section 22.2.1) or a repeated group name (section 22.2.1.1, where the 11th edition's 21.2.1.1 refuses any repeat) require the fixture's refusal instead. The evaluator still refuses all 47. Name the edition where the documentation describes the dialect, and, with the suite now passing on Node 24, run the whole TypeScript suite in the CI leg at the 24 and 26 floors instead of only the discovery tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
llhttp_finish()on EOF-like socket terminationContent-Lengthmismatch error behaviorClientandfetch()Details
Undici previously treated EOF on non-keepalive responses as an implicit successful message completion. That is correct for EOF-delimited responses, but not for chunked responses, which must receive the terminating
0\r\n\r\nchunk.This change routes the EOF/close/ECONNRESET path through
llhttp_finish()so llhttp can reject incomplete chunked responses with an invalid EOF state instead of completing the response body successfully.Testing
node --test test/parser-issues.js test/content-length.jsnpx eslint lib/dispatcher/client-h1.js test/parser-issues.js