You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A waiting held lease can't be cancelled: SIGINT is ignored until grant, a killed CLI's request stays queued, and the CLI has no cancel #1249
simlock 0.5.0, one gateway and one worker. A held simlock lease --platform ios --bind-pid <pid> --timeout 30m (run on the gateway's machine, so it goes through the gateway) was waiting in the queue. Then:
SIGINT to the CLI while it waits: the process stays alive and the request stays queued. cli/commands/lease.js races termination.settled only after client.requestLease() resolves, so a signal or a dead --bind-pid process during the wait is noticed only at grant time, when the device is released at once.
SIGTERM / kill of the CLI while it waits: the CLI exits, but the gateway keeps the request queued (seen in simlock status as a waiter for minutes). When it is reached, device work starts for a requester that is gone (DELETE /v1/lease-requests/<id> then answers 409 REQUEST_NOT_CANCELLABLE), and the grant is never released before its TTL.
The CLI has no way to cancel a waiting request: simlock release takes only a lease id (UNKNOWN_LEASE for a request id), and simlock release --all run as admin releases every requester's leases, not only the caller's.
What I expected
A held simlock lease that gets SIGINT/SIGTERM, or whose --bind-pid process exits, while it waits cancels its request (as the programmatic client's abort does) and exits.
A request whose client connection is gone leaves the queue (or the gateway cancels it when the socket closes).
A CLI way to cancel: simlock lease cancel [--platform ios] for the calling requester, matching the daemon's lease.cancel.
simlock release --all limited to the calling requester unless --any-requester is given; it surprised us as admin.
Why it matters
A test runner that is stopped while waiting for a simulator either keeps its place in the queue, or later takes a device nobody will release, and it blocks everyone behind it on a worker with two slots.
Defect, confirmed for SIGINT, SIGTERM and --bind-pid exit. Test on bug/1249-repro: src/cli/index.test.ts, "cancels its waiting request and exits 0 on $trigger before a grant".
pnpm exec vitest run --project unit src/cli/index.test.ts -t "cancels its waiting request"
× cancels its waiting request and exits 0 on SIGINT before a grant
× cancels its waiting request and exits 0 on SIGTERM before a grant
× cancels its waiting request and exits 0 on the exit of the --bind-pid process before a grant
AssertionError: expected undefined to be true
❯ expect(requestSignal?.aborted).toBe(true);
Corrections: the CLI catches SIGTERM the same way it catches SIGINT, so a CLI that exited while waiting was SIGKILLed. A killed CLI's request staying queued is ADR 0004 §3 ("connection close means nothing to a lease", src/daemon/server.ts:1388); changing that needs a superseding ADR. simlock lease cancel and a narrower release --all (documented as "every lease") are feature requests.
Root cause
src/cli/commands/lease.ts:93-95 sets up the signal and --bind-pid handlers before the request, which turns off Node's default exit. But client.requestLease (lease.ts:182) gets no signal, and termination.settled is awaited only at lease.ts:231, after the grant. So while the request waits, the signal is caught and does nothing. The client already cancels a request when its signal aborts (src/simlock-client/client.ts:863: lease.cancel, then it releases a grant that lands anyway).
Simplest fix
In runLease, abort an AbortController when termination.settled resolves. Pass its signal to requestLease. Return 0 when the request rejects with CANCELLED after that abort. Exit 0 is the shape the test pins (like "0 after it released the lease on request"). I tried this locally: all 414 tests in the file pass.
Alternatives rejected
Cancel when the daemon socket closes: goes against ADR 0004 §3.
Exit 1 (CANCELLED's code): a stop the caller asked for is not a failure.
Risk
--detach has no termination watch and must still send no signal.
A grant that lands during the cancel must be released and not printed to stdout.
cli.mdx should say a signal also cancels a waiting request.
A held simlock lease that gets SIGINT or SIGTERM, or whose --bind-pid (or parent) process exits, while its request waits cancels that request and exits 0, as the triage report's simplest fix says. The failing test on bug/1249-repro is the regression test. (decided in delivery, pending the maintainer)
Out of scope: a simlock lease cancel command, limiting release --all to the caller, and the gateway cancelling a request when its connection closes (ADR 0004 §3). (decided in delivery, pending the maintainer)
Tests: "cancels its waiting request and exits 0 on $trigger before a grant" (src/cli/index.test.ts), one case each for SIGINT, SIGTERM and the --bind-pid exit.
Merged: #1316 (#1249)
Parked: none
Waiting: none
Decided: #1249 — scope of the fix → only the CLI cancels its waiting request on SIGINT, SIGTERM or the --bind-pid/parent exit; lease cancel, release --all scoping and gateway cancel-on-close left out
Activity
V3RON commentedon Nov 5, 2026
Reproduction
Defect, confirmed for SIGINT, SIGTERM and
--bind-pidexit. Test onbug/1249-repro:src/cli/index.test.ts, "cancels its waiting request and exits 0 on $trigger before a grant".Corrections: the CLI catches SIGTERM the same way it catches SIGINT, so a CLI that exited while waiting was SIGKILLed. A killed CLI's request staying queued is ADR 0004 §3 ("connection close means nothing to a lease",
src/daemon/server.ts:1388); changing that needs a superseding ADR.simlock lease canceland a narrowerrelease --all(documented as "every lease") are feature requests.Root cause
src/cli/commands/lease.ts:93-95sets up the signal and--bind-pidhandlers before the request, which turns off Node's default exit. Butclient.requestLease(lease.ts:182) gets nosignal, andtermination.settledis awaited only atlease.ts:231, after the grant. So while the request waits, the signal is caught and does nothing. The client already cancels a request when its signal aborts (src/simlock-client/client.ts:863:lease.cancel, then it releases a grant that lands anyway).Simplest fix
In
runLease, abort anAbortControllerwhentermination.settledresolves. Pass itssignaltorequestLease. Return 0 when the request rejects withCANCELLEDafter that abort. Exit 0 is the shape the test pins (like "0 after it released the lease on request"). I tried this locally: all 414 tests in the file pass.Alternatives rejected
CANCELLED's code): a stop the caller asked for is not a failure.Risk
--detachhas no termination watch and must still send no signal.cli.mdxshould say a signal also cancels a waiting request.Written by an agent.
V3RON commentedon Nov 5, 2026
Scope
simlock leasethat gets SIGINT or SIGTERM, or whose--bind-pid(or parent) process exits, while its request waits cancels that request and exits 0, as the triage report's simplest fix says. The failing test onbug/1249-reprois the regression test. (decided in delivery, pending the maintainer)simlock lease cancelcommand, limitingrelease --allto the caller, and the gateway cancelling a request when its connection closes (ADR 0004 §3). (decided in delivery, pending the maintainer)--bind-pidexit.Written by an agent.
chore(merge): merge origin/main into bug/1249 (#1249)
V3RON commentedon Nov 5, 2026
Delivery run
Merged: #1316 (#1249)
Parked: none
Waiting: none
Decided: #1249 — scope of the fix → only the CLI cancels its waiting request on SIGINT, SIGTERM or the
--bind-pid/parent exit;lease cancel,release --allscoping and gateway cancel-on-close left outWritten by an agent.
fix(cli): a held lease cancels its waiting request on a signal or the…