fix(stream): align readable unshift end handling - #2484
Merged
proggeramlug merged 3 commits intoMay 29, 2026
Merged
Conversation
# Conflicts: # test-parity/known_failures.json
proggeramlug
pushed a commit
that referenced
this pull request
Jun 11, 2026
…d chunk #5017 changed read() with no size to always return the head chunk. Node's howMuchToRead(NaN) is flowing-conditional: it yields one chunk at a time only while flowing; while paused it returns the entire buffer (state.length) concatenated. The blanket change dropped everything past the first chunk for paused readers — e.g. push("world"); unshift("hello "); read() returned "hello " instead of "hello world" — regressing the #2484/#4386 unshift unit tests (cargo-test gate red on main). Restore the flowing branch: flowing -> head chunk (keeps #1545 boundary behavior for for-await / 'readable' drain loops); paused -> drain-all concat. Both node_stream unshift tests green again; full perry-runtime suite passes (the unrelated date::test_full_year_setters_revive_invalid_date_only failure is a pre-existing macOS-only timezone flake, green on CI Linux).
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
ERR_STREAM_UNSHIFT_AFTER_END_EVENTerror only after the readableendevent has been emittedReadable.unshift(chunk[, encoding])after EOF has been signaled but beforeend, so pushed-back chunks drain before the stream endsreadable/unshiftsliceVerification
./run_parity_tests.sh --suite node-suite --filter stream/readable/unshift-after-endPASS 1/0/0 (test-parity/reports/parity_report_20260529_084325.json)./run_parity_tests.sh --suite node-suite --filter stream/readable/unshift-with-encodingPASS 1/0/0 (test-parity/reports/parity_report_20260529_084326.json)./run_parity_tests.sh --suite node-suite --module stream --filter readable/unshiftPASS 8/0/0 (test-parity/reports/parity_report_20260529_084715.json)cargo test -p perry-runtime readable_unshift_after_eof_before_end_prepends_chunkcargo check -p perry-runtimecargo fmt --checkjq empty test-parity/known_failures.jsongit diff --checkgit diff --cached --checkNotes
DeepWiki references:
reference/deepwiki/nodejs-node-stream-readable-unshift-after-end-2026-05-29.mdreference/deepwiki/nodejs-node-stream-readable-unshift-encoding-2026-05-29.mdThe final branch tip is
fc7253ec9after rebasing onto the updated PR branch.