From 1b0d1a2d5637a8d705c8585edfa6d179a093bffd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 24 Oct 2026 05:26:27 +0200 Subject: [PATCH] Test: the loss is made after the service-document rewrite has finished, so only the daemon's own ask can notice it Co-Authored-By: Claude Opus 5.5 --- scripts/test-vili-daemon.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/test-vili-daemon.mjs b/scripts/test-vili-daemon.mjs index c6c14f6..2838c52 100644 --- a/scripts/test-vili-daemon.mjs +++ b/scripts/test-vili-daemon.mjs @@ -1112,8 +1112,8 @@ test("the entry derives the daemon's host, port, interpreter and environment ide }); // The lease is asked while a generate awaits its worker, not only when the service documents are rewritten. The -// bound is one WATCH_MS ask plus the SIGKILL; the test allows a second. The loss is made right after a rewrite, the -// longest wait for an implementation that asks only then. +// bound is one WATCH_MS ask plus the SIGKILL; the test allows a second. The loss is made just after a rewrite of the +// service documents (whose own gates have asked), the longest wait for an implementation that asks only then. test("a worker still writing when the lease is lost is dead within a second", async () => { const daemon = await idunnDaemon({ leased: true }); try { @@ -1133,6 +1133,7 @@ test("a worker still writing when the lease is lost is dead within a second", as const [worker] = daemon.spawns(); const rewritten = statSync(store).mtimeMs; await until(() => statSync(store).mtimeMs !== rewritten, "the service documents to be rewritten", 8); + await new Promise((resolve) => setTimeout(resolve, 150)); // the rewrite is done: its own gates have asked const lostAt = Date.now(); rmSync(daemon.lease); await until(() => !isAlive(worker), "the worker to die", 10);