Skip to content

Commit df64c69

Browse files
test(scripts): publish escaped child readiness after IPC closes
The escaped-output fixture previously announced readiness before its IPC handshake finished. A watchdog could kill the parent first, causing an unhandled EPIPE and invalidating the intended live-pipe cleanup scenario. Publish readiness from the disconnect event after the handshake. The original whole-file run passed 50 tests; forcing that ordering reproduced the exact CI assertion failure. The repaired whole file passes 50 tests under normal scheduling and 50 with the same forced ordering. Deadlines, cleanup assertions and production code are unchanged. Co-authored-by: zhang-guiping <[email protected]>
1 parent 0b15ca8 commit df64c69

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎test/scripts/managed-child-process.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,11 @@ const keepAlive = setInterval(() => {
973973
process.stderr.write('drained-err');
974974
}
975975
}, ${mode === "normal drainage" ? 5 : 1000});
976-
fs.writeFileSync(${JSON.stringify(pidPath)} + '.tmp', String(process.pid));
977-
fs.renameSync(${JSON.stringify(pidPath)} + '.tmp', ${JSON.stringify(pidPath)});
976+
// The watchdog may kill the parent as soon as readiness is published.
977+
process.once('disconnect', () => {
978+
fs.writeFileSync(${JSON.stringify(pidPath)} + '.tmp', String(process.pid));
979+
fs.renameSync(${JSON.stringify(pidPath)} + '.tmp', ${JSON.stringify(pidPath)});
980+
});
978981
process.send('ready');
979982
process.disconnect();
980983
`;

0 commit comments

Comments
 (0)