run: drain piped child stdout/stderr to prevent Ralph loop deadlock#194
Open
selimdev00 wants to merge 2 commits into
Open
run: drain piped child stdout/stderr to prevent Ralph loop deadlock#194selimdev00 wants to merge 2 commits into
selimdev00 wants to merge 2 commits into
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.
Problem
In dashboard and swarm mode,
spawnRalphLoopspawns the loop withstdio: ["ignore", "pipe", "pipe"], but nothing ever consumes the child's stdout/stderr — the dashboards read progress from.ralph/state files, not from the pipe.Node child-process pipes start paused. Once the loop (and the agent CLI it drives) writes more than the OS pipe buffer (~64KB), the child blocks on
write()indefinitely. The loop then hangs forever:onExitnever fires, sobmalph run --dashboardandbmalph run --swarm(where every worker is spawned this way) stall and never resolve. It only takes one verbose agent turn to cross 64KB.Fix
When stdio is piped (
inheritStdio === false), put both streams into flowing mode so their buffers drain and the child can always make progress:This preserves existing behavior (dashboard mode already shows state-file progress, not raw child output) while removing the deadlock. The
inheritStdio === truepath is unchanged. Output is discarded, same as today — a follow-up could instead tee each stream to a per-worker log file under.ralph/logs/for swarm debugging.Tests
stdout.resume()/stderr.resume()are each called once wheninheritStdiois false.