Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/runtime-core/src/frame-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ export class StdioFrameTransport<TReadFrame, TWriteFrame = TReadFrame>
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 {
Expand Down Expand Up @@ -262,6 +268,7 @@ export class StdioFrameTransport<TReadFrame, TWriteFrame = TReadFrame>
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();
Expand Down