From 4fd3f60c883691d1f542954d28c9166a55e6fb5d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 24 Oct 2026 01:33:22 +0200 Subject: [PATCH] Test: a second daemon that fails to refuse is killed, not left holding the test run open Co-Authored-By: Claude Opus 5.5 --- scripts/test-vili-daemon.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/test-vili-daemon.mjs b/scripts/test-vili-daemon.mjs index 1e64857..bbc8ff3 100644 --- a/scripts/test-vili-daemon.mjs +++ b/scripts/test-vili-daemon.mjs @@ -693,11 +693,12 @@ const snapshotRequest = (messageId = "m1") => Buffer.from(encode({ schemaVersion // A second daemon on a state root a live daemon holds must refuse, and must not touch the first one's worker. test("a second daemon on a live state root exits 2 and kills nothing", async () => { const first = await startDaemon(); + let second = null; try { assert.equal((await generate(first)).status, 200); const [worker] = first.spawns(); assert.ok(isAlive(worker)); - const second = await startDaemon({ root: first.root, hold: false }); + second = await startDaemon({ root: first.root, hold: false }); await until(() => second.proc.exitCode !== null, "the second daemon to refuse", 20); assert.equal(second.proc.exitCode, 2); assert.match(second.stderr(), /held by a running daemon/); @@ -705,6 +706,7 @@ test("a second daemon on a live state root exits 2 and kills nothing", async () assert.equal((await generate(first)).status, 200); assert.equal(aliveWorkers(first).length, 1); } finally { + if (second && second.proc.exitCode === null && second.proc.signalCode === null) second.proc.kill("SIGKILL"); // a daemon that failed to refuse must not outlive the test await first.stop(); } });