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 lease.cancel through a gateway refuses a fleet request that is not queued yet, so an early abort leaves it standing #1492
What happens. Suspected, not reproduced: a lease.cancel through a gateway for a fleet request that is not queued yet answers not-cancellable, and the request then goes on to queue or be dispatched. That is the same race #1479 fixed on a worker (PR #1485). The client's abort then leaves the request standing, so a killed simlock --gateway lease can still end up holding a device until its TTL.
Where.FleetLeaseCoordinator.cancelPending (src/gateway/fleet-coordinator.ts:386-398) answers not-cancellable for any waiter whose state !== "queued". #1479's fix on the worker made a waiter that is still resolving its spec cancellable, and made lease.cancel wait for the same requester's not-yet-admitted lease.request. The gateway has neither change. #1479's triage report flagged it as a risk.
Seen. Code reading only, on main after #1485 merged. Nothing was run through a gateway.
Confirmed. src/gateway/fleet-requests.test.ts, "FleetLeaseCoordinator: a lease.cancel sent right after its lease.request (#1492)", two cases: a fleet with no room (the request would queue) and a free worker (it would be dispatched). Each expects cancelled, a RequestCancelledError, nothing waiting and no lease.request to the worker. Without the cancel, the same fixtures do queue and dispatch. Branch bug/1492-repro.
pnpm exec vitest run --project unit src/gateway/fleet-requests.test.ts -t 1492
× with no room, so the request would queue, answers cancelled, ...
× with a free worker, so the request would be …, answers cancelled, ...
AssertionError: expected 'not-cancellable' to be 'cancelled'
❯ src/gateway/fleet-requests.test.ts:1658:27
Root cause
src/gateway/fleet-coordinator.ts:395 refuses every waiter not queued. request() creates the waiter (state new) inside its decision and calls #admit only after #decisions.run returns, so a cancel queued behind that decision runs first and sees new. ADR 0005 §10 asks for the codes a worker uses, and since #1485 a worker cancels a new waiter. A correction to the issue: the second half of #1485 (waiting for a not-yet-admitted request) is not needed here. GatewayDispatcher#leaseRequest reaches the coordinator's FIFO decision with no await in between, so the cancel always finds the waiter.
Activity
V3RON commentedon Nov 10, 2026
Reproduction
Confirmed.
src/gateway/fleet-requests.test.ts, "FleetLeaseCoordinator: a lease.cancel sent right after its lease.request (#1492)", two cases: a fleet with no room (the request would queue) and a free worker (it would be dispatched). Each expectscancelled, aRequestCancelledError, nothing waiting and nolease.requestto the worker. Without the cancel, the same fixtures do queue and dispatch. Branchbug/1492-repro.Root cause
src/gateway/fleet-coordinator.ts:395refuses every waiter notqueued.request()creates the waiter (statenew) inside its decision and calls#admitonly after#decisions.runreturns, so a cancel queued behind that decision runs first and seesnew. ADR 0005 §10 asks for the codes a worker uses, and since #1485 a worker cancels anewwaiter. A correction to the issue: the second half of #1485 (waiting for a not-yet-admitted request) is not needed here.GatewayDispatcher#leaseRequestreaches the coordinator's FIFO decision with noawaitin between, so the cancel always finds the waiter.Simplest fix
#admitthen finds the waiter terminal:markProcessingandenqueuerefuse it, and no RPC goes out.Alternatives rejected
UnadmittedRequeststo the gateway dispatcher: it has no window to cover.#admitfor a terminal waiter: same result, a second guard.Risk
newwaiter still walks once in#admitand claims a worker for that pass, but it sends nothing.processing(forwarded, before the worker's answer) staysnot-cancellable, as on a worker. A killed CLI there keeps the lease until its TTL.newis seen only when both frames are dispatched in one tick, for example from a single socket read.Fast track
Written by an agent.
fix(gateway): drop a redundant walk guard; EVENTS names the cancellab…
V3RON commentedon Nov 10, 2026
Delivery run
Merged: #1493 (#1492)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(gateway): a lease.cancel right after its lease.request cancels th…
test(core): random interleavings of lease requests are checked agains…