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:
parent
5aa27c45f1
commit
26cf06ed9f
2 changed files with 27 additions and 0 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue