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
flaky: gateway-handover.test.ts B10 open test sees no connected worker within 10 s on the Windows unit job #2097
bug:readyAn agent may fix it.fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.os:windowsRuns on, or affects, Windows hosts
src/agent-device/gateway-handover.test.ts, "the agent-device front under a handover credential, through a gateway > B10: open attaches agent-device on the handed-over lease's worker and leases nothing", failed on the Windows unit job (shard 2/3) on PR #2087, at 5f193ec, attempt 1 of the CI run (job). The same job run also failed src/report-guard.test.ts and src/agent-device/edge-allocate.test.ts. A re-run of the run (attempt 2) passed.
This one is not the 20 s test timeout. setUp() waits up to 10 s (untilRead, vi.waitFor) for the gateway's worker.list to show the worker as connected, and the wait ran out with no worker view at all:
FAIL unit src/agent-device/gateway-handover.test.ts > the agent-device front under a handover credential, through a gateway > B10: open attaches agent-device on the handed-over lease's worker and leases nothing
AssertionError: expected undefined to be 'connected' // Object.is equality
- Expected:
"connected"
+ Received:
undefined
❯ vi.waitFor.timeout src/agent-device/test-gateway.ts:359:32
What you expected
The worker is connected within 10 s, and the test passes on every run.
How to reproduce
Not reproduced locally: it runs on Windows only. Seen once, on 2026-12-03. The shard ran 384 s and three files failed, so a loaded runner is a likely cause, not a known one.
Environment
CI: windows-2025, job Unit tests (Windows) (2/3), pnpm run test:unit (20 s test timeout; the untilRead wait is 10 s).
Seen on: CI log, Windows unit shard 2/3 (worker logs stay in memory, so the failed dial on CI is inferred, not read)
When a worker's first uplink dial fails, the rig's setUp() never sees that worker. Two workers; the first dial is refused once. It fails exactly as CI did.
src/agent-device/gateway-rig-redial.test.ts, "answers setUp with every worker connected and read when a worker's first uplink dial fails", on bug/2097-repro:
pnpm exec vitest run --project unit src/agent-device/gateway-rig-redial.test.ts
AssertionError: expected undefined to be 'connected' // Object.is equality
❯ vi.waitFor.timeout src/agent-device/test-gateway.ts:359:32
Root cause
Defect. untilRead (src/agent-device/test-gateway.ts:355-366) waits 10 s of real time and never moves the rig's FakeClock. When a dial fails, GatewayUplink (src/daemon/gateway-uplink.ts:143 → #scheduleRetry, line 166) schedules the redial on that clock (clock.setTimer). So the rig turns one failed handshake into a worker that never joins. On a loaded runner a dial can fail: the handshake has a real 10 s timeout (uplink-websocket.ts:51). The gateway never got a hello, so its view is undefined, as on CI. untilRedialed (line 749) already moves the clock for this; setUp does not.
Simplest fix
If the worker is still not connected after about 2 s of polling, move the clock while waiting, the way untilRedialed does:
pnpm exec vitest run --project unit src/agent-device/gateway-rig-redial.test.ts src/agent-device/gateway-*.test.ts
Test Files 9 passed (9) Tests 99 passed (99)
Alternatives rejected
Advancing the clock on every poll where the worker is not connected moves the clock during normal setUps too. Two gateway-front-reconnect.test.ts tests failed (expected 32000 to be 31000).
A longer untilRead timeout does not help: a redial on the fake clock never fires, however long the wait.
A startDaemon uplink-backoff option adds a daemon option only tests use.
Risk
A dial still in flight after about 2 s now gets the clock moved; a test reading deadlines could fail differently.
The fix does not help a runner that is starved for the whole 10 s. Only the failed-dial case is fixed.
bug:readyAn agent may fix it.fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.os:windowsRuns on, or affects, Windows hosts
Activity
V3RON commentedon Dec 3, 2026
Reproduction
Seen on: CI log, Windows unit shard 2/3 (worker logs stay in memory, so the failed dial on CI is inferred, not read)
When a worker's first uplink dial fails, the rig's
setUp()never sees that worker. Two workers; the first dial is refused once. It fails exactly as CI did.src/agent-device/gateway-rig-redial.test.ts, "answers setUp with every worker connected and read when a worker's first uplink dial fails", onbug/2097-repro:Root cause
Defect.
untilRead(src/agent-device/test-gateway.ts:355-366) waits 10 s of real time and never moves the rig'sFakeClock. When a dial fails,GatewayUplink(src/daemon/gateway-uplink.ts:143→#scheduleRetry, line 166) schedules the redial on that clock (clock.setTimer). So the rig turns one failed handshake into a worker that never joins. On a loaded runner a dial can fail: the handshake has a real 10 s timeout (uplink-websocket.ts:51). The gateway never got a hello, so its view isundefined, as on CI.untilRedialed(line 749) already moves the clock for this;setUpdoes not.Simplest fix
If the worker is still not connected after about 2 s of polling, move the clock while waiting, the way
untilRedialeddoes:export async function untilRead(rig: Rig, member: Member): Promise<void> { + let polls = 0; await vi.waitFor( async () => { const view = await viewOf(rig, member.label); + polls += 1; + if (view?.connection !== "connected" && polls > 40) await advance(rig, 1_000, 500);Alternatives rejected
gateway-front-reconnect.test.tstests failed (expected 32000 to be 31000).untilReadtimeout does not help: a redial on the fake clock never fires, however long the wait.startDaemonuplink-backoff option adds a daemon option only tests use.Risk
Fast track
Written by an agent.
fix(test): only the rig's set-up moves the clocks for a failed first …
V3RON commentedon Dec 3, 2026
Delivery run
Merged: #2099 (#2097)
Written by an agent.