Skip to content

fix(stream): align readable unshift end handling - #2484

Merged
proggeramlug merged 3 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-readable-unshift-after-end-error
May 29, 2026
Merged

fix(stream): align readable unshift end handling#2484
proggeramlug merged 3 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-readable-unshift-after-end-error

Conversation

@andrewtdiz

@andrewtdiz andrewtdiz commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • emit the Node-compatible ERR_STREAM_UNSHIFT_AFTER_END_EVENT error only after the readable end event has been emitted
  • allow Readable.unshift(chunk[, encoding]) after EOF has been signaled but before end, so pushed-back chunks drain before the stream ends
  • remove stale known-failure entries for the now-green readable/unshift slice

Verification

  • ./run_parity_tests.sh --suite node-suite --filter stream/readable/unshift-after-end PASS 1/0/0 (test-parity/reports/parity_report_20260529_084325.json)
  • ./run_parity_tests.sh --suite node-suite --filter stream/readable/unshift-with-encoding PASS 1/0/0 (test-parity/reports/parity_report_20260529_084326.json)
  • ./run_parity_tests.sh --suite node-suite --module stream --filter readable/unshift PASS 8/0/0 (test-parity/reports/parity_report_20260529_084715.json)
  • cargo test -p perry-runtime readable_unshift_after_eof_before_end_prepends_chunk
  • cargo check -p perry-runtime
  • cargo fmt --check
  • jq empty test-parity/known_failures.json
  • git diff --check
  • git diff --cached --check

Notes

DeepWiki references:

  • reference/deepwiki/nodejs-node-stream-readable-unshift-after-end-2026-05-29.md
  • reference/deepwiki/nodejs-node-stream-readable-unshift-encoding-2026-05-29.md

The final branch tip is fc7253ec9 after rebasing onto the updated PR branch.

@andrewtdiz andrewtdiz changed the title fix(stream): error on unshift after end fix(stream): align readable unshift end handling May 29, 2026
@proggeramlug
proggeramlug merged commit 94533f0 into PerryTS:main May 29, 2026
11 checks passed
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants