From cd3299235bb2c0b31c59d4533510b0c751b55b66 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Tue, 17 Dec 2024 13:17:11 +0300 Subject: [PATCH] fix: force stdio destroy on `abort/child.kill()` --- src/main/ts/spawn.ts | 4 ++++ target/cjs/spawn.cjs | 4 ++++ target/esm/spawn.mjs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/main/ts/spawn.ts b/src/main/ts/spawn.ts index 5b89f3e..4b3c7c2 100644 --- a/src/main/ts/spawn.ts +++ b/src/main/ts/spawn.ts @@ -251,6 +251,10 @@ export const invoke = (c: TSpawnCtxNormalized): TSpawnCtxNormalized => { error = e c.ee.emit('err', error, c) }) + .once('exit', () => { + child.stdout?.destroy() + child.stderr?.destroy() + }) .once('close', (status, signal) => { c.fulfilled = { error, diff --git a/target/cjs/spawn.cjs b/target/cjs/spawn.cjs index f6ab523..9f58bcd 100644 --- a/target/cjs/spawn.cjs +++ b/target/cjs/spawn.cjs @@ -192,6 +192,10 @@ var invoke = (c) => { child.once("error", (e) => { error = e; c.ee.emit("err", error, c); + }).once("exit", () => { + var _a3, _b3; + (_a3 = child.stdout) == null ? void 0 : _a3.destroy(); + (_b3 = child.stderr) == null ? void 0 : _b3.destroy(); }).once("close", (status, signal) => { var _a3; c.fulfilled = { diff --git a/target/esm/spawn.mjs b/target/esm/spawn.mjs index 62f7f7e..393d0b4 100644 --- a/target/esm/spawn.mjs +++ b/target/esm/spawn.mjs @@ -171,6 +171,10 @@ var invoke = (c) => { child.once("error", (e) => { error = e; c.ee.emit("err", error, c); + }).once("exit", () => { + var _a3, _b3; + (_a3 = child.stdout) == null ? void 0 : _a3.destroy(); + (_b3 = child.stderr) == null ? void 0 : _b3.destroy(); }).once("close", (status, signal) => { var _a3; c.fulfilled = {