Repository navigation
stream: run a replaced write() in the flowing pipe - #66596
Open
nigrosimone wants to merge 1 commit into
Open
nigrosimone wants to merge 1 commit into
nigrosimone wants to merge 1 commit into
Conversation
pipe() calls dest.write(). The fast path of a flowing pipe hands the chunks of a source that pushes from _read() to dest._write() directly, so a write() replaced on the instance or overridden in a subclass no longer runs. A response that is a Writable, wrapped by compression middleware, sent a gzip body with uncompressed chunks in it. Take the fast path only when write() is Writable.prototype.write. Refs: nodejs#66182 Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
Collaborator
|
Review requested:
|
Member
|
@nigrosimone this seems good, why it's draft? |
Contributor
Author
|
@mcollina my local build is still running, I want to see the test pass there first. Ready in about an hour, or I can mark it ready now and let the CI run, if you prefer. |
nigrosimone
marked this pull request as ready for review
October 8, 2026 08:53
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66596 +/- ##
=======================================
Coverage 90.44% 90.44%
=======================================
Files 791 791
Lines 276562 276565 +3
Branches 53126 53116 -10
=======================================
+ Hits 250130 250138 +8
+ Misses 16846 16834 -12
- Partials 9586 9593 +7
🚀 New features to boost your workflow:
|
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.
pipe()callsdest.write(), but since #66182 a flowing pipe whose source pushes from_read()hands each chunk todest._write()directly. Awrite()replaced on the destination, or overridden in a subclass, no longer runs.Found on 26.11.1 with a framework whose response is a
stream.Writable: compression middleware replacesres.write(), and a file piped to the response came out as a gzip body with uncompressed chunks in it (Z_DATA_ERRORon the client). 26.10.0 is fine.Fix: take the fast path only when
write()isWritable.prototype.write.Test:
test/parallel/test-stream-pipe-replaced-write.js, onewrite()replaced on the instance and one in a subclass. It fails on 26.11.1 (1 call towrite()out of 64) and passes with the fix.cc @anonrig
Disclosure: I used Opus 5.5 (Max) as coding assistant