Repository navigation
Conversation
🦋 Changeset detectedLatest commit: e932232 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
This branch is waiting to be deployed
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.
Type
Description
A pipeline built with
ChildProcess.pipeTohangs forever when a stage before the last one writes more than about 128 KiB (about 1 MiB on Bun) to an output that is not piped to the next stage. Examples are a first stage that logs heavily to stderr with the defaultfrom: "stdout", the documentedmake\my-program`.pipe(pipeTo(make`grep error`, { from: "stderr" }))when the program writes normal stdout, or a busy middle stage of three. The same command run on its own completes, because theChildProcessSpawner` helpers drain output they do not return (#9846).In the
PipedCommandcase every stage is spawned with piped stdout and stderr, but only the stream forwarded to the next stage is read. The other output is never read and is not reachable from the returned handle, so the stage blocks writing to a full pipe, never closes the stream it forwards, and the last stage never sees EOF.Each non-final stage's unforwarded outputs are now drained and discarded in a fiber owned by that stage's scope, and the forwarded stream joins that fiber through
Stream.drainFork, the same primitive #9846 uses. Draining lasts for the stage's lifetime, so a stage that closes its forwarded output early and keeps writing to the other one still completes. A drain failure while the forwarded stream is open (for example a failingSinkon stage 1's stderr) fails the next stage's input, as it does for the single-command helpers. Outputs that are not piped (inherit,ignore, a file descriptor) are already empty streams, so explicit options are unchanged. Inheriting the unforwarded outputs, as a shell does for stderr, was not used because it would print a stage's output to the host process's terminal.The Node spawner (also used by Bun) covers
from: "stdout","stderr","all"and"fdN"plus other output file descriptors; the Deno spawner covers stdout, stderr and all. On Deno, the drain releases its reader lock rather than cancelling the stream when the scope closes, so an unref'd stage that is still running keeps an open pipe, as before.Verification
The same probe on both versions; stage 1 is
sh -c 'head -c 300000 /dev/zero >&2; echo payload'piped tocat, with a 2 second timeout:The new shared-suite tests for heavy stderr from a non-final stage, heavy stdout with
{ from: "stderr" }, and output written after the forwarded stream ends time out without the fix on Node, the Node proxy process layer and Deno, and pass with it. The fourth test keeps an unref'd stage's pipe open after the scope closes on Deno. Rootpnpm checkandpnpm lintpassed; the Node (222), Bun (6) and Deno (82 passed, 14 skipped) spawner tests and theeffectprocess tests passed.