Skip to content

Flaky: gateway-front restart test does not see the worker connected within 10 s #573

Closed

Description

@V3RON

src/agent-device/gateway-front.test.ts > the agent-device front, through a gateway: after a gateway restart > after a gateway restart, a command, a release, devices and an upload with the lease header, each as the token's first request, work on the adopted lease

Failed in CI run 38569310207 (PR #567, 31ac3af) and run 38583522717 (PR #565, e8d4707): untilRead (line 348) saw viewOf(...) return undefined within its 10 s real-time wait, after restarted() advanced the fake clock 8 s. The test restarts the gateway four times, so the redial back-off is at its largest and the wait is tight on a loaded runner. Not reproduced locally: 20 runs on the feature branch and 20 on main, all green.

Written by an agent.

Activity

  1. added
    flaky-test
    on Oct 14, 2026
  2. self-assigned this
    on Oct 16, 2026
  3. V3RON commented on Oct 16, 2026

    @V3RON
    ContributorAuthor

    This was generated by AI during triage.

    Reproduction

    Already fixed by PR #570, merged 31 minutes after this issue was opened. The reported test passes on current main; no new failing test or reproduction commit is justified.

    # HEAD: 7533c442953444f395e8bdbd9ee36da51e37a517
    pnpm exec vitest run --project unit src/agent-device/gateway-front.test.ts -t "after a gateway restart, a command, a release, .*devices.* and an upload with the lease header, each as the token's first request, work on the adopted lease"
    # Test Files 1 passed (1)
    # Tests 1 passed | 73 skipped (74)
    # Duration 2.43s; tests 896ms

    The reported failing run used 3539bccf, which still has the fixed 8-second advance. No failure was reproduced on current main.

    Root cause

    Defect in the test harness. Historical restarted() advanced the fake clock once, then untilRead() waited in real time without moving it. The worker's reconnect is scheduled on that fake clock (src/daemon/gateway-uplink.ts:172–191) with growing, jittered backoff (:201–205). A retry scheduled beyond the fixed advance cannot run while real-time polling waits. Current src/agent-device/gateway-front.test.ts:2002–2014 already drives the clock until the worker reconnects, within a 30-second wall-time bound.

    Simplest fix

    Already delivered in 22cd25892: advance fake time while disconnected, then await the refreshed view and adopted leases. Retain this fix and verify it independently before closing the stale issue.

    Alternatives rejected

    • Increase real-time polling only: fake timers remain stationary.
    • Change production backoff: the defect belongs to the test's clock driver.
    • Add another test: the reported test already proves the four first-request paths.

    Risk

    • One passing run does not prove all loaded-runner schedules.
    • Keep the reconnect wait bounded and retain all four request assertions.

    Written by an agent.

  4. assigned and unassigned on Oct 16, 2026
  5. V3RON commented on Oct 16, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done

    Already fixed by PR #570, merged as 22cd25892. Independently verified the retained fix on main at 7533c442953444f395e8bdbd9ee36da51e37a517:

    pnpm exec vitest run --project unit src/agent-device/gateway-front.test.ts -t "after a gateway restart, a command, a release, .*devices.* and an upload with the lease header, each as the token's first request, work on the adopted lease"
    # Test Files 1 passed (1)
    # Tests 1 passed | 73 skipped (74)
    # Tests 959 ms; duration 5.78 s

    Not done

    Nothing. No additional patch is needed; closing as completed.

    Findings

    restarted() advances fake time while disconnected under a 30-second bound. This removes the reported stalled-clock failure. All four first-request assertions remain. One passing run does not establish every loaded-runner schedule.

    Blocked on

    Nothing.

    Written by an agent.

  6. removed their assignment
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    flaky-test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions