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
simlock lease ignores a SIGTERM in its first second, and the request it then queues outlives the process #1473
What happens. A SIGTERM that reaches simlock lease during its first second is lost. The command keeps running, and its request is sent and queued anyway. A second SIGTERM then kills the process with exit 143 (no handler), and the request stays queued. When a device frees up, the request is granted to a requester that no longer exists, so the device is held until the lease's TTL. #1316 promises that a signal while the request waits cancels it and exits 0. That does work once the request is queued, and when a --bind-pid process exits.
Where. Likely src/cli/commands/lease.ts:187. The termination watch is armed before connectDaemonClient, and on settle it calls waitAbort.abort() only if ourLeaseId is unset. A signal that arrives before client.requestLease(...) is called aborts a controller the request then gets already aborted, and nothing checks signal.aborted before sending. Not confirmed.
Seen.main at 30f8fad9, macOS arm64. With capacity.strategy=fixed, capacity.config.maxRunning=1 and one iOS lease held by agent a:
15 s later the process is still alive, and simlock list --requests shows b, ios class phone, queued at 1. A second kill -TERM exits 143, and the request is still queued. In another run, the request outlived its process and was granted a lease (lease.granted, no lease.rejected with reason:"cancelled"). The same signal sent after list --requests shows the request as queued exits 0, prints nothing on stdout and cancels it (lease.rejected with reason:"cancelled").
Found during the pre-release e2e pass after v0.6.0.
Defect, confirmed. A signal during the connect is turned into an abort only after the request is on the wire. The window after the send is a second defect, in the client: #1479.
src/cli/index.test.ts, "sends no lease request and exits 0 on $trigger while it connects" (SIGINT, SIGTERM, --bind-pid exit), on bug/1473-repro:
pnpm exec vitest run --project unit src/cli/index.test.ts -t "while it connects"
× ... on SIGINT / SIGTERM / the exit of the --bind-pid process while it connects
AssertionError: expected 1 to be +0
❯ src/cli/index.test.ts:7366:26 expect(sentRequests).toBe(0);
Root cause
src/cli/commands/lease.ts:187. The termination.settled.then(...) that aborts waitAbort is attached after await connectDaemonClient (line 98), which lazy-loads the admin client. A signal during the connect resolves settled, but the callback runs one microtask after client.requestLease (line 195) has already checked signal.aborted (client.ts:618) and sent the frame. The abort then sends lease.cancel, which the daemon answers not-found because the request is not admitted yet. The client waits on a request that is now queued (#1479). finish (termination.ts:21) has already removed the handlers, so the second SIGTERM kills with 143.
Simplest fix
Move let ourLeaseId, waitAbort, cancelledWhileWaiting and the settled.then block (with its why:) above connectDaemonClient. The client then rejects CANCELLED with nothing sent.
pnpm exec vitest run --project unit src/cli/index.test.ts
Tests 425 passed (425)
Activity
V3RON commentedon Nov 9, 2026
Reproduction
Defect, confirmed. A signal during the connect is turned into an abort only after the request is on the wire. The window after the send is a second defect, in the client: #1479.
src/cli/index.test.ts, "sends no lease request and exits 0 on $trigger while it connects" (SIGINT, SIGTERM,--bind-pidexit), onbug/1473-repro:Root cause
src/cli/commands/lease.ts:187. Thetermination.settled.then(...)that abortswaitAbortis attached afterawait connectDaemonClient(line 98), which lazy-loads the admin client. A signal during the connect resolvessettled, but the callback runs one microtask afterclient.requestLease(line 195) has already checkedsignal.aborted(client.ts:618) and sent the frame. The abort then sendslease.cancel, which the daemon answersnot-foundbecause the request is not admitted yet. The client waits on a request that is now queued (#1479).finish(termination.ts:21) has already removed the handlers, so the second SIGTERM kills with 143.Simplest fix
Move
let ourLeaseId,waitAbort,cancelledWhileWaitingand thesettled.thenblock (with itswhy:) aboveconnectDaemonClient. The client then rejectsCANCELLEDwith nothing sent.Alternatives rejected
terminationbeforerequestLease: a signal during the connect would still race the call.Risk
ourLeaseIdmust move above the connect with the block. Otherwise a signal during the connect hits the TDZ.Fast track
Side findings
Written by an agent.
docs(cli): the manual says a signal while connecting sends no request (…
test(cli): move the connect-signal test out of the shrink-only index.…
V3RON commentedon Nov 9, 2026
Delivery run
Merged: #1482 (#1473)
Parked: none
Waiting: none
Decided: none
Asleep: 15 min
Written by an agent.
fix(cli): a signal during connect sends no lease request (callstackin…