feat(fs): compiled ReadStream/WriteStream event+option parity (#980, part 2 of 2)#1009
Merged
Conversation
…part 2 of 2) Completes #980 — brings the compiled $FsReadStream/$FsWriteStream to parity with the interpreter (epic #968's final child). Achieved via a replay approach rather than event-loop deferral: the compiled entry point does not run the loop for a raw $EventLoop.Schedule'd action in a top-level program (a #971-family quiescence issue), so deferral never fired. Instead, lifecycle events are emitted at creation and re-emitted to late listeners via an OnListenerAdded override — exactly how the base $Readable already replays 'end'. No event loop involved. $FsReadStream: emits open/ready/close (replay) in Node order; reads honoring fd/start/end/encoding into highWaterMark chunks (multiple 'data' events via the base buffer); honors autoClose/emitClose; adds Pending; option parsing handles $Undefined-for-absent (GetProperty returns $Undefined, not null). $FsWriteStream: reparented from `object` onto $EventEmitter (was a non-emitter with a no-op On stub) — now a real emitter with open/ready/finish/close; honors flags/fd/start/autoClose/emitClose; Write handles byte[]/$Buffer/string so pipe() moves content; adds Pending/bytesWritten. 8 dual-mode parity tests (read events+chunking+bytesRead, emitClose+start/end, write events+bytesWritten+content, pipe). Byte-identical interp==compiled, standalone preserved. Full suite 14480/0; TS conformance unchanged. Known minor divergence: compiled reads eagerly (pending=false right after createReadStream) vs interp's deferred read (pending=true until the tick); AbortSignal abort is interpreter-only in this path (compiled AbortSignal, #985).
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.
Completes #980 (epic #968's final child). Part 1 (the interpreter half) merged via #1008; this PR is part 2 — the compiled
$FsReadStream/$FsWriteStreamrewrite, bringing the compiled backend to parity with the interpreter.What changed
$FsReadStream: emitsopen/ready/closevia anOnListenerAddedreplay (exactly how the base$Readablealready replaysend— no event loop); chunks byhighWaterMark(multipledataevents); honorsfd/start/end/encoding/emitClose/autoClose; addsPending/bytesRead.$FsWriteStream: reparented fromobjectonto$EventEmitter(was a non-emitter with a no-opOnstub) — now emitsopen/ready/finish/close, honorsflags/fd/start/autoClose/emitClose,Writehandlesbyte[]/$Buffer/string sopipe()moves content; addsPending/bytesWritten.Why replay, not deferral
The compiled entry point doesn't run the event loop for a raw
$EventLoop.Scheduled action in a top-level program (a #971-family quiescence issue — the action provably never fired), so deferral was abandoned in favor of replay, which needs no event loop.Verification
8 dual-mode parity tests (read events+chunking+bytesRead, emitClose+start/end, write events+bytesWritten+content, pipe read→write). Byte-identical interp==compiled, standalone preserved. Full suite 14480/0; TS conformance unchanged.
Minor documented divergences: compiled reads eagerly (
pending=falseright aftercreateReadStreamvs interptrue); AbortSignal abort is interpreter-only here (compiled AbortSignal limitation, #985). Merging this completes epic #968.