1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix(node): child_process kill cancel pending IPC reads (#21647)

This commit is contained in:
Divy Srivastava 2023-12-20 07:55:09 +05:30 committed by GitHub
parent 5aa27c45f1
commit 26cf06ed9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -731,3 +731,26 @@ Deno.test(function spawnSyncExitNonZero() {
assertEquals(ret.status, 22);
});
// https://github.com/denoland/deno/issues/21630
Deno.test(async function forkIpcKillDoesNotHang() {
const testdataDir = path.join(
path.dirname(path.fromFileUrl(import.meta.url)),
"testdata",
);
const script = path.join(
testdataDir,
"node_modules",
"foo",
"index.js",
);
const p = Promise.withResolvers<void>();
const cp = CP.fork(script, [], {
cwd: testdataDir,
stdio: ["inherit", "inherit", "inherit", "ipc"],
});
cp.on("close", () => p.resolve());
cp.kill();
await p.promise;
});

View file

@ -296,6 +296,10 @@ export class ChildProcess extends EventEmitter {
throw err;
}
}
/* Cancel any pending IPC I/O */
this.disconnect?.();
this.killed = true;
this.signalCode = denoSignal;
return this.killed;