You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bash tool never returns when a spawned command leaves a descendant holding its stdio pipes #50316
The bash tool never returns for a command that starts a background service. The command's own process exits, the service comes up, and the tool call waits forever. Two independent waits keep it open:
packages/core/src/cross-spawn-spawner.ts resolves the exit deferred on close. Node only emits close after the child's stdio streams have closed, and a detached descendant that inherits stdout/stderr keeps those pipes open — so for a server, close never fires. @effect/platform-node resolves the same signal on exit.
packages/core/src/process.ts reads handle.all / handle.stdout / handle.stderr to end of stream. Those reads wait on the same held-open pipes, so fixing (1) alone does not unblock run — verified by reverting either half on its own: the hang comes back either way.
The command prints done and exits, but the tool call does not return.
Measurements
Same command shape: exit fires at ~125 ms, close at ~3160 ms when the grandchild lives 3 s. When the descendant is a server, close never fires at all. That gap is the hang.
Stopping the output read at exit does not truncate output: outstanding bytes at exit measured 0 for payloads up to 64 MiB (a child cannot exit before it has finished writing, because it blocks on the pipe buffer until the reader drains it).
A regression test that spawns a detached grandchild and expects the run to settle with its output intact fails (times out) if either half above is reverted on its own.
Suggested fix
Resolve the spawner's exit deferred on exit (close kept only as a fallback).
Stop reading output at exit, e.g. handle.all.pipe(Stream.interruptWhen(handle.exitCode)), at all four collection sites in process.ts: combineOutput, stdout, stderr, and runStream.
Related
Open PRs in this area: #42275 and #42756 (spawner only), #44601 (both files), #45407, #49857. Per the measurements above, the spawner-only ones are not sufficient on their own.
Activity