fix(api): swallow EPIPE on dead worker stdin write (BIT-31194) #3

Merged
spark merged 1 commits from fix/BIT-31194-line-process-epipe into main 2026-10-15 06:26:47 +01:00
+4
View File
@@ -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);