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 command answered WORKER_UNREACHABLE keeps its lease renewed until the run limit #545
Through a gateway, when a command is answered WORKER_UNREACHABLE because the uplink dropped mid-command, the front keeps renewing that command's simlock lease until the run limit (maxRunMs) or until the CLI hangs up. The agent was told "try again", so it may have given up, but the device stays held for the whole run limit.
What should happen
A lease the agent no longer uses stops being renewed soon after the unreachable answer, without ending a command that may still be running on the worker.
Context
Recorded as Assumption 5 on #539 (task #517): renewals continue because the command may still run on the worker, and the renewal-tick spec test needs the timer to stay. Feature #511.
Pushed failing reproduction to bug/545-repro, commit 1d840078. No PR.
Run pnpm exec vitest run --project unit src/agent-device/gateway-front.test.ts: 73 pass, 1 fails. The extended mid-command test grants a 30-second lease, holds a command that survives request abort, drops the real uplink, consumes the 503 WORKER_UNREACHABLE answer, reconnects, and advances across two renewal ticks without a heartbeat. At line 1908, the deadline is 51,000, expected 31,000. No explicit lease release occurs.
Root cause
Defect:src/agent-device/front/front.ts:170 returns the unreachable response without calling end() or wrapping its body in untilBodyEnds. The renewal reference survives; src/agent-device/front/renewals.ts:70 leaves its cleanup to maxRunMs. Reconnect makes those retained ticks renew successfully. This is the behavior recorded in #539 Assumption 5.
Simplest fix
End this command's renewal reference on the unreachable response, preserving the map entry and worker command. Account for Renewals.#finish's existing final renewal. Update the adjacent reconnect-renewal test and module manual that currently require retained renewals.
Alternatives rejected
Release the lease immediately: can interrupt a command still running on the worker.
Cancel every renewal for the lease: would affect concurrent commands still awaiting replies.
Wait for maxRunMs: preserves the reported device retention.
Risk
Ordinary TTL expiry can eventually end worker work; stopping renewals must not explicitly release it.
Preserve heartbeat recovery and renewal references belonging to other live commands.
Activity
V3RON commentedon Oct 19, 2026
Reproduction
Pushed failing reproduction to
bug/545-repro, commit1d840078. No PR.Run
pnpm exec vitest run --project unit src/agent-device/gateway-front.test.ts: 73 pass, 1 fails. The extended mid-command test grants a 30-second lease, holds a command that survives request abort, drops the real uplink, consumes the 503WORKER_UNREACHABLEanswer, reconnects, and advances across two renewal ticks without a heartbeat. At line 1908, the deadline is 51,000, expected 31,000. No explicit lease release occurs.Root cause
Defect:
src/agent-device/front/front.ts:170returns the unreachable response without callingend()or wrapping its body inuntilBodyEnds. The renewal reference survives;src/agent-device/front/renewals.ts:70leaves its cleanup tomaxRunMs. Reconnect makes those retained ticks renew successfully. This is the behavior recorded in #539 Assumption 5.Simplest fix
End this command's renewal reference on the unreachable response, preserving the map entry and worker command. Account for
Renewals.#finish's existing final renewal. Update the adjacent reconnect-renewal test and module manual that currently require retained renewals.Alternatives rejected
maxRunMs: preserves the reported device retention.Risk
fix(agent-device): stop renewing commands answered unreachable (#723)