Skip to content

A command answered WORKER_UNREACHABLE keeps its lease renewed until the run limit #545

Closed

Description

@V3RON

What happens

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.

Written by an agent.

Activity

  1. added
    bug:new
    and removed
    bug:new
    on Oct 14, 2026
  2. self-assigned this
    on Oct 19, 2026
  3. V3RON commented on Oct 19, 2026

    @V3RON
    ContributorAuthor

    This was generated by AI during triage.

    Reproduction

    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.
  4. removed their assignment
    on Oct 19, 2026
  5. added
    bug:ready
    and removed on Oct 19, 2026
  6. self-assigned this
    on Oct 19, 2026
  7. added a commit that references this issue on Oct 20, 2026
    36e072e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions