Stream child stdout live so long-running blocks don't look stalled#127
Merged
Stream child stdout live so long-running blocks don't look stalled#127
Conversation
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
options.streamtorun(). When true, each child'sstdoutchunk is written toprocess.stdoutas it arrives. Captured stdout is still accumulated intoresult.stdoutfor programmatic callers — streaming is additive, not destructive.src/cli.jspassesstream: trueand drops the finalprocess.stdout.write(stdout)since it would just duplicate what's already been streamed.stderris still captured silently and written at the end (unchanged) soformatErrorcan produce its pretty summary without being interleaved with raw Node error output.Why
run.jsused to buffer every child's stdout into a string, wait for the child to exit, return it, and only then let the CLI print it. Blocks that take a while — a network call, a long loop, or anything waiting on I/O — gave zero feedback until they finished. A user staring at a blank terminal has no way to tell the difference between "this is working" and "this is stuck."The typical "progress" path is
console.log, i.e. stdout. Streaming stderr too would mean raw Node error output followed by the formattedFAILsummary on every failure — extra noise in the common case — so stderr keeps the old buffered behaviour.Test plan
test/fixtures/stream-delay.mdprintsSTREAM-MARKER, sleeps 500ms, then asserts1 //=> 1.child_process.spawn, records whenSTREAM-MARKERfirst appears on stdout, then waits for exit. It asserts the marker arrived at least 200 ms before the child exited — i.e., the output is live, not buffered. The test takes ~577 ms locally (500 ms fixture sleep + overhead).markerAt < total - 200is false.node --test test/*.test.js— 65/65 pass (64 before + 1 new).pnpm -r test— all 10 workspace examples still green.