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
requestLease aborted before the daemon queues the request leaves it queued and the call pending #1479
An abort that reaches SimlockClient.requestLease after the frame is sent but before the daemon admits the request is lost. The client sends lease.cancel, the daemon answers not-found because the request is not queued yet, and #cancelOnAbort (src/simlock-client/client.ts:916) treats that as ADR 0003 §10's "after the grant resolved" case and waits on the request. The request is then queued, so the call never settles and the request outlives its caller.
lease.request awaits #requireCapabilities and the spec resolve (outside the lock) before it admits (src/daemon/dispatcher.ts:533), and lease.cancel has no such step, so the cancel wins.
Seen with a probe against startTestDaemon in src/cli/index.test.ts (iOS limit 1, one lease held by a): requestLease({ requesterId: "b" }, { signal }), controller.abort() one microtask later, 50 macrotasks of settle:
PROBE state pending waiting [{"id":"req_id1","requesterId":"b",...,"stage":"queued","queuePosition":1,"reason":"device-limit"}]
Every frontend that aborts (simlock lease on a signal, MCP) has this window. Found while triaging #1473.
src/daemon/server-roles.test.ts, "a requestLease aborted right after its frame is sent, with the device limit held, rejects CANCELLED and its request ends cancelled, not by its queue timeout", on bug/1479-repro. The cancel answers not-found on every run, as reported.
pnpm exec vitest run --project unit src/daemon/server-roles.test.ts -t "aborted right after its frame"
AssertionError: expected SimlockError: Timed out waiting for a dev… to match object { code: 'CANCELLED' }
- "code": "CANCELLED",
+ "code": "QUEUE_TIMEOUT",
Root cause
Defect, two windows. #leaseCancel (src/daemon/dispatcher.ts:596) runs cancelPending at once, before the same requester's lease.request is admitted: await this.#requireCapabilities (:533) yields even with no requires, then the request waits for the lock. So: not-found. Correction: the spec resolve runs after admission, and is the second window: cancelPending (src/leasing/lease-acquisition-coordinator.ts:799) answers not-cancellable for a waiter still new (resolving its spec, no device work). Either way the client (src/simlock-client/client.ts:916, :944) waits on a request that then queues.
Simplest fix
One PR, two changes:
Dispatcher: per requester, a promise for each lease.request not yet admitted, resolved on onAdmitted or when the call settles. #leaseCancel awaits them before cancelPending.
cancelPending: not-cancellable only for processing; a new waiter is rejected like a queued one (#nextPlan skips a rejected waiter). Update its doc comment.
Done: PR #1485 fixes both windows from the triage. The dispatcher holds a lease.cancel until the same requester's unadmitted lease.request is admitted or settles, and cancelPending rejects a new waiter. Review: round 1 raised one blocking finding (the finally release had no test). It is fixed and verified, and a later fix-check passed. CI's size-limit failure is fixed by moving the tracking into src/daemon/unadmitted-requests.ts. The PR is ready for review.
Not done: merge.
Findings: the gateway's cancelPending (src/gateway/fleet-coordinator.ts:393) has the same check, but it was not reproduced and is out of scope.
Blocked on: fast-track: #1479 held: PR #1485 changes 272 lines, over 250. The maintainer merges the PR, or removes fast-track.
Activity
V3RON commentedon Nov 9, 2026
Reproduction
src/daemon/server-roles.test.ts, "a requestLease aborted right after its frame is sent, with the device limit held, rejects CANCELLED and its request ends cancelled, not by its queue timeout", onbug/1479-repro. The cancel answersnot-foundon every run, as reported.Root cause
Defect, two windows.
#leaseCancel(src/daemon/dispatcher.ts:596) runscancelPendingat once, before the same requester'slease.requestis admitted:await this.#requireCapabilities(:533) yields even with norequires, then the request waits for the lock. So:not-found. Correction: the spec resolve runs after admission, and is the second window:cancelPending(src/leasing/lease-acquisition-coordinator.ts:799) answersnot-cancellablefor a waiter stillnew(resolving its spec, no device work). Either way the client (src/simlock-client/client.ts:916,:944) waits on a request that then queues.Simplest fix
One PR, two changes:
Dispatcher: per requester, a promise for eachlease.requestnot yet admitted, resolved ononAdmittedor when the call settles.#leaseCancelawaits them beforecancelPending.cancelPending:not-cancellableonly forprocessing; anewwaiter is rejected like a queued one (#nextPlanskips a rejected waiter). Update its doc comment.Alternatives rejected
lease.cancelon the firstqueuedpush: a client retry its manual forbids.awaitwhenrequiresis empty: leaves the lock order to frame timing.Risk
cancelPending(src/gateway/fleet-coordinator.ts:393) has the samequeued-only check; not reproduced.allowDownload, a cancellednewwaiter leaves its runtime install running.Fast track
Written by an agent.
fix(daemon): a cancel waits for its requester's unadmitted lease requ…
test(daemon): a cancel waiting on a lease request refused before admi…
fix(daemon): keep dispatcher.ts within its size limit by moving the u…
fix(daemon): point the complexity waiver at the wrapped lease.request…
V3RON commentedon Nov 9, 2026
Handoff
Done: PR #1485 fixes both windows from the triage. The dispatcher holds a
lease.canceluntil the same requester's unadmittedlease.requestis admitted or settles, andcancelPendingrejects anewwaiter. Review: round 1 raised one blocking finding (thefinallyrelease had no test). It is fixed and verified, and a later fix-check passed. CI's size-limit failure is fixed by moving the tracking intosrc/daemon/unadmitted-requests.ts. The PR is ready for review.Not done: merge.
Findings: the gateway's
cancelPending(src/gateway/fleet-coordinator.ts:393) has the same check, but it was not reproduced and is out of scope.Blocked on:
fast-track: #1479 held: PR #1485 changes 272 lines, over 250.The maintainer merges the PR, or removesfast-track.Written by an agent.
V3RON commentedon Nov 9, 2026
Delivery run
Merged: none
Parked: #1479 — PR #1485 held by the fast track (272 lines, over 250)
Asleep: 15 min
Written by an agent.
fix(daemon): an abort before the daemon admits a lease request cancel…
test(core): random interleavings of lease requests are checked agains…