Skip to content

Commit

Permalink
fix: force stdio destroy on abort/child.kill()
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Dec 17, 2024
1 parent 4d8a870 commit cd32992
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/ts/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions target/cjs/spawn.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 4 additions & 0 deletions target/esm/spawn.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit cd32992

Please sign in to comment.