Repository navigation
test: avoid setTimeout in broken gzip body regression test - #6002
Merged
metcoder95 merged 1 commit intoNov 12, 2026
Merged
Conversation
The regression test for nodejs#5999 used a wall-clock setTimeout to make the invalid gzip body arrive in a later packet than the response headers. Wall-clock timers are flaky and add a fixed delay to every run. Instead, defer the body to a later event-loop tick with setImmediate. This deterministically splits the headers and body into separate packets without any wall-clock dependency, and the test still hangs on the pre-fix code while rejecting fast on the current one. Refs: nodejs#5999
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6002 +/- ##
==========================================
- Coverage 91.57% 91.56% -0.01%
==========================================
Files 113 113
Lines 43664 43664
==========================================
- Hits 39984 39981 -3
- Misses 3680 3683 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Nov 12, 2026
Merged
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.
This relates to...
Refs #5999
Rationale
The regression test for #5999 (added to complement the existing fetch fix) used a wall-clock
setTimeoutto make the invalid gzip body arrive in a later packet than the response headers. Wall-clock timers are flaky and add a fixed delay (100ms) to every run.This replaces the
setTimeoutwith asetImmediatedeferral, which is a deterministic event-loop scheduling primitive with no wall-clock dependency.Why two
setImmediateticksThe regression only manifests when the invalid gzip body arrives in a separate packet than the headers, so the fetch controller's
terminatedlistener is removed inonCompletebefore decompression fails. Verified empirically:setImmediatecoalesces into the same packet and does not reproduce.setImmediatereliably splits the headers and body into separate packets.A genuine I/O "logical event" is not usable here:
'drain'never fires for tiny header writes, andreq.on('end')never fires because undici aborts the request upload when the server sends the response headers early.Verification
mainit rejects fast withTypeError/Z_DATA_ERROR.test/fetch/encoding.js: 9/9 pass (new test ~3ms).standardlint: clean.Status