Repository navigation
Commit 64a33e3
committed
fix(cli): exit cleanly on closed stdout (EPIPE) instead of spinning
When the reader on the far end of stdout/stderr closes the pipe (e.g.
`opencode run --format json | head`), the CLI process kept generating
output to a dead sink: the run event loop, SSE heartbeats and log writes
continued firing, and the write failures surfaced as EPIPE stream errors
with no listener (or were swallowed by the worker's no-op uncaughtException
handler), so the process never exited and spun at 100% CPU.
Install an `error` listener on process.stdout/stderr at the CLI entry point
that exits 0 on EPIPE (closed pipe) and rethrows every other error, so real
stream failures still surface and normal-exit behavior is unchanged.
Fixes anomalyco#336531 parent 1af4d5d commit 64a33e3
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
0 commit comments