The ignoreTerm tool child was TERMed before Node installed its handler when the claim store sits on a fast disk. Candidate fixes the fixture; the patch itself is not committed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
18 lines
963 B
JavaScript
18 lines
963 B
JavaScript
// Spawn the K fixtures' ignoreTerm child exactly as fake-pi.mjs spawnChild does, then
|
|
// SIGTERM it after a delay. Reports how the child ended within 1 s.
|
|
import { spawn } from "node:child_process";
|
|
const code = "const note=()=>{};process.on('SIGTERM',()=>note('term'));setInterval(()=>{},1e9)";
|
|
const delays = process.argv.slice(2).map(Number);
|
|
for (const d of delays) {
|
|
const r = { died: 0, survived: 0 };
|
|
for (let i = 0; i < 10; i++) {
|
|
const c = spawn(process.execPath, ["-e", code], { stdio: "ignore" });
|
|
const ended = new Promise((res) => c.on("exit", (code, sig) => res(sig ?? code)));
|
|
await new Promise((res) => setTimeout(res, d));
|
|
c.kill("SIGTERM");
|
|
const out = await Promise.race([ended, new Promise((res) => setTimeout(() => res(null), 1000))]);
|
|
if (out === null) { r.survived++; c.kill("SIGKILL"); await ended; } else r.died++;
|
|
}
|
|
console.log(`TERM ${d} ms after spawn: died ${r.died}/10 survived ${r.survived}/10`);
|
|
}
|