fix(api): swallow EPIPE on dead worker stdin write (BIT-31194) #3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user