fix(stream): gate no-size read() head-chunk behavior on flowing mode#5031
Closed
proggeramlug wants to merge 1 commit into
Closed
fix(stream): gate no-size read() head-chunk behavior on flowing mode#5031proggeramlug wants to merge 1 commit into
proggeramlug wants to merge 1 commit into
Conversation
…1545 follow-up) PR #5017 made read() with no size return only the head chunk of the internal buffer unconditionally. Node's howMuchToRead(NaN) only does that when the stream is FLOWING (state.flowing && state.length); a paused stream drains the entire buffer and returns it as one value. This broke two cargo-test unit tests on main (unshift prepend tests expect 'hello world' from a paused read()) and with it every PR's required cargo-test check. Fix: keep the head-chunk path for flowing streams, restore the full-drain concat path (drain_whole_buffer) for paused streams.
This was referenced Jun 12, 2026
Closed
Closed
Contributor
Author
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
Unbreaks
cargo-testonmain(every open PR is currently red on it).PR #5017 changed
Readable.read()with no size to return only the head chunk of the internal buffer unconditionally. Node'showMuchToRead(NaN)only does that when the stream is flowing:A paused stream drains the entire buffer and returns it as a single value, which is exactly what the two now-failing unit tests assert:
node_stream::tests_extra::readable_unshift_prepends_chunk_and_returns_hwm_signalnode_stream::tests_extra::readable_unshift_after_eof_before_end_prepends_chunk(
push('world'); unshift('hello '); read()→'hello world', verified against real Node.)Fix
read_stream_available_defaultkeeps the #5017 head-chunk path whenreadable_is_flowing(stream)and restores the pre-#5017 full-drain concat path (drain_whole_buffer, including the string-encoding branch) when paused. Sizedread(n)is untouched.Validation
cargo test --release -p perry-runtime --lib node_stream→ 68 passed, 0 failed (both previously-failing tests pass).perry-runtime --libsuite: only the two known macOS-local pre-existing failures remain (date full_year, Date.prototype.toJSON); both also fail on unmodifiedorigin/mainlocally and are green in Linux CI.Note: the remaining
mainreds are tracked separately — #5029 (gc_write_barrier_stress) and #5030 (h1_buffer_alias_negative); fixes in flight.No version bump / changelog per external-PR convention — maintainer folds metadata at merge.