Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 046d603c207808c711351ae45ebe8b2496bf8e28
parent 72d1d96ba67ad08b0f5e638dbdeb5193545e427f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 10 Oct 2026 14:24:44 -0400

e2e: a queue or heavy-slot waiter stopped by a signal cleans up after itself

A run killed while it waited (a `timeout`, Ctrl-C) died on the default handler
and left its holder file naming a dead pid. The handlers are now installed
before the wait, and with no command running they exit through process.exit,
so the 'exit' cleanups run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mscripts/queue-lock.mjs | 3+++
Mscripts/queue-lock.test.mjs | 15+++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/scripts/queue-lock.mjs b/scripts/queue-lock.mjs @@ -1263,6 +1263,9 @@ async function prebuild(pkg) { async function main() { const { opts, cmd: rawCmd } = parseArgv(process.argv.slice(2)); if (opts.hold) return runHolder(); + // While waiting (no command yet) a signal exits through process.exit, so the + // 'exit' cleanups run: no holder file is left naming a dead waiter. + installSignalHandlers(); // `pnpm heavy -- <cmd>` may hand the separator through as the first word. const cmd = opts.heavy && rawCmd[0] === "--" ? rawCmd.slice(1) : rawCmd; if (cmd.length === 0) { diff --git a/scripts/queue-lock.test.mjs b/scripts/queue-lock.test.mjs @@ -755,3 +755,18 @@ test("--prebuild ensures the suite's build before its admission, and the config assert.doesNotMatch(bad.stdout, /checked=/); assert.match(bad.stderr, /the nope e2e build failed/); }); + +test("a waiter stopped by SIGTERM leaves no holder file behind", async () => { + const dir = tmpDir(); + const env = heavyEnv(dir); + const first = startLock(["--heavy", "--", process.execPath, "-e", "setTimeout(()=>{},1500)"], env); + await until(() => fs.existsSync(`${env.HEAVY_LOCK_FILE}.holder.json`)); + const waiter = startLock(["--heavy", "--", "true"], env); + await waiter.waitFor(/waiting for the heavy slot/); + assert.ok(fs.existsSync(`${env.HEAVY_LOCK_FILE}.admit.holder.json`), "the waiter holds the line"); + waiter.child.kill("SIGTERM"); + const res = await waiter.done; + assert.equal(res.code, 128 + os.constants.signals.SIGTERM); + assert.equal(fs.existsSync(`${env.HEAVY_LOCK_FILE}.admit.holder.json`), false); + assert.equal((await first.done).code, 0); +});