From 4a06596b71a07097a627bd4f72ce2c7edb561a56 Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Sun, 19 Jul 2026 00:52:47 -0700 Subject: [PATCH] fix(runtime-core): handle stdin error events in StdioFrameTransport --- packages/runtime-core/src/frame-stream.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/runtime-core/src/frame-stream.ts b/packages/runtime-core/src/frame-stream.ts index 8a6ba35772..3460731f0e 100644 --- a/packages/runtime-core/src/frame-stream.ts +++ b/packages/runtime-core/src/frame-stream.ts @@ -221,6 +221,12 @@ export class StdioFrameTransport this.stdout.on("data", this.handleData); this.stdout.on("end", this.handleEnd); this.stdout.on("error", this.handleError); + // The write side needs its own error listener. Without it, a failed + // write (e.g. EPIPE when the sidecar process dies) emits an 'error' + // event with no listener, which Node throws as an uncaught exception + // and kills the host process (LT-013). Route it to the transport's + // error listeners so callers see a normal, typed transport error. + this.stdin.on("error", this.handleError); } onFrame(handler: (frame: TReadFrame) => void): () => void { @@ -262,6 +268,7 @@ export class StdioFrameTransport this.stdout.off("data", this.handleData); this.stdout.off("end", this.handleEnd); this.stdout.off("error", this.handleError); + this.stdin.off("error", this.handleError); this.frameListeners.clear(); this.errorListeners.clear(); this.endListeners.clear();