diff --git a/apps/api/src/lib/line-process.ts b/apps/api/src/lib/line-process.ts index 7ff3a12..09650c2 100644 --- a/apps/api/src/lib/line-process.ts +++ b/apps/api/src/lib/line-process.ts @@ -21,6 +21,10 @@ export class LineProcess { if (this.ready) return this.ready; const child = spawn(this.opts.bin, this.opts.args ?? [], { stdio: ["pipe", "pipe", "pipe"] }); this.child = child; + // Writing to stdin after the child has died (e.g. mid-request crash) raises EPIPE; without + // this listener the unhandled "error" event on the stream kills the whole Node process. + // The "exit" handler below still rejects any pending requests. + child.stdin.on("error", () => {}); let stderr = ""; child.stderr.on("data", (d: Buffer) => { stderr = (stderr + d.toString()).slice(-2000);