Repository navigation
stream: keep data buffered during synchronous flow - #67599
Open
jakecastelli wants to merge 1 commit into
Open
jakecastelli wants to merge 1 commit into
jakecastelli wants to merge 1 commit into
Conversation
The flowing fast path keeps the prefetched chunk off the buffer and resets `state.length` before each `_read()`. A chunk put on the buffer by `unshift()` or `push()` from a 'data' listener while a prefetched chunk was pending was not accounted for, so it was never delivered and the stream ended with data still buffered. Move the prefetched chunk onto the buffer before `unshift()` and `push()` add to it. That keeps the chunks in order and makes the fast path fall back to `read()`. Also leave the fast push mode when `_read()` calls `unshift()`, `read()` or `setEncoding()`. A following `push()` then adds to the buffer and goes through the decoder instead of overwriting `state.length` or delivering an undecoded chunk. Signed-off-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com> Assisted-by: claude:fable-5.2
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67599 +/- ##
==========================================
- Coverage 90.73% 90.72% -0.01%
==========================================
Files 801 801
Lines 280787 280810 +23
Branches 54221 54220 -1
==========================================
+ Hits 254765 254777 +12
+ Misses 16203 16198 -5
- Partials 9819 9835 +16
🚀 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.
The flowing fast path keeps the prefetched chunk off the buffer and
resets
state.lengthbefore each_read(). A chunk put on the bufferby
unshift()orpush()from a 'data' listener while a prefetchedchunk was pending was not accounted for, so it was never delivered and
the stream ended with data still buffered.
Move the prefetched chunk onto the buffer before
unshift()andpush()add to it. That keeps the chunks in order and makes the fastpath fall back to
read().Also leave the fast push mode when
_read()callsunshift(),read()orsetEncoding(). A followingpush()then adds to thebuffer and goes through the decoder instead of overwriting
state.lengthor delivering an undecoded chunk.Fixes: #67598
Assisted-by: claude, manually reviewed by a human