Repository navigation
Description
Summary
An unhandled write EPIPE in the host daemon's parcel watcher channel crashes the entire daemon. Every thread running on that host dies with "Thread interrupted because the host daemon disconnected", losing whatever work was in flight.
This has fired 5 times on my host (bb-app 0.36.0, Linux, node v22.22.3). Two of those crashes killed 8 threads outright, including three recovery threads that had each been working for ~1h20m.
Root cause
packages/host-watcher/src/parcel-subprocess/fork-channel.ts:37-41
send(message: ParentToChildMessage) {
if (child.connected) {
child.send(message);
}
},child.connected is not a sufficient guard: it stays true while the IPC channel is tearing down, so child.send() can still fail with EPIPE. There is no try/catch, no send callback, and no 'error' listener on the child.
The proxy pings the child from a bare setInterval (parcel-watcher-proxy.ts:129-155), so the throw has nothing above it to catch — it escapes as an uncaughtException and takes down the daemon:
Error: write EPIPE
at target._send (node:internal/child_process:877:20)
at target.send (node:internal/child_process:751:19)
at Object.send (bb-app/host-daemon/dist/daemon-bundle.mjs:44:827)
at Timeout._onTimeout (bb-app/host-daemon/dist/daemon-bundle.mjs:44:1550)
at listOnTimeout (node:internal/timers:585:17)
Why the race opens
The window is widest exactly when the daemon is already unhealthy. Both of my recent crashes were preceded by severe event-loop starvation:
"msg":"Host daemon event loop stalled","maxDelayMs":11542.7,"meanDelayMs":11538.5
"msg":"Host daemon heartbeat timer delayed","gapMs":403139,"heartbeatIntervalMs":5000
"msg":"Watcher child unresponsive; killing","sinceLastPongMs":21436
A stalled event loop delays the ping timer well past a child's exit — so when the timer finally fires, the child is gone but its exit event has not been processed and connected is still true. The ping goes into a dead pipe and the daemon dies.
Timeline from my host (all UTC, 2026-08-12):
| Time | Event |
|---|---|
| 21:03:52 | last log line, gapMs: 317452 |
| 21:03–21:17 | daemon logs nothing (stalled) |
| 21:17:18 | write EPIPE uncaughtException, daemon dies |
| 21:17:53 | daemon restarts; 3 threads already lost |
The irony is that createParcelWatcherProxy is explicitly built to survive a dying child — it kills, respawns, and replays every subscription. The one path it doesn't survive is the send that discovers the child is dead.
Impact
The blast radius is the whole host, not the watcher. A file-watcher IPC hiccup terminates every running agent thread, and long-running threads are the most expensive ones to lose. The failure also isn't provider-specific — my crashes took out codex and claude-code threads together.
Fix
PR incoming: make the channel's send non-throwing and treat a send failure as "this child is gone", reporting it through the exit path the proxy already recovers from — plus an 'error' listener, since an unhandled 'error' event on the ChildProcess is the same fatal outcome by another route.
Note this only addresses the crash. The underlying event-loop stalls are a separate issue; after the fix the watcher recycles cleanly instead of taking the daemon with it.
AGENT GENERATED: by Claude Opus 5
Activity
AndrewSB commentedon Aug 13, 2026
Fix up in #1506 — makes the channel's
sendnon-throwing and routes a failed send through the exit path the proxy already self-heals from, plus an'error'listener for the other unhandled route.Regression-tested by reverting the guard: 4 of the 5 new cases fail with exactly the EPIPE escape.
Bind the channel once when replaying subscriptions
Survive a broken pipe to the watcher child (#1506)
chore: sync upstream 2026-08-18 (#6)