Skip to content

flaky: main-update.test.ts version check test times out at 20 s on the Windows unit job #1913

Done

Description

@V3RON

What happened

src/daemon/main-update.test.ts, "startDaemon version check > a daemon runs the version check at start without delaying ready, then after 24 h, and reports a newer latest in status.get and the daemon.update query; npm failing or answering junk keeps the last value; a stopped daemon never schedules the next check", timed out on the Windows unit job on two branches that do not touch the daemon:

Commit Where CI run
c130b35 chore/pstack-slow-lane (agent config, two script tests) 45621989246
b4088fe feature/1832-adr (ADR only) 45570704146
Error: Test timed out in 20000ms.
 ❯ src/daemon/main-update.test.ts:291:3

Both runs are from 2026-11-25, before #1886 changed the version check and this file. It is not among the Windows-only failures since; triage may find it fixed.

What you expected

The test passes on every run.

How to reproduce

Not reproduced locally. No failed run was re-run in place; the commits above change no code the test reads, and the test passes on the runs around them.

Environment

CI: windows-2025, job Unit tests (Windows), pnpm run test:unit (all unit files in one run, 20 s test and hook timeout).

Written by an agent.

Activity

  1. added
    bug:new
    flaky-test
    on Nov 27, 2026
  2. self-assigned this
    on Nov 28, 2026
  3. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Not fixed by #1886/#1887: on main (7efa617) the test still takes 11 s of 20 s. Every daemon this file starts runs a real powershell.exe to read the data directory's ACL; the test starts five.

    src/daemon/test-daemons-host-load.test.ts on bug/1913-repro, "daemons started by tests under src/ > pass a directoryAccess reader, so none starts PowerShell on Windows to read its data directory's ACL". It reuses the hostLoadProbe guard's scanner, with the option name as a parameter.

    $ pnpm exec vitest run --project unit src/daemon/test-daemons-host-load.test.ts
    × pass a directoryAccess reader, so none starts PowerShell on Windows to read its data directory's ACL
    AssertionError: expected [ …(67) ] to deeply equal []
    +   "src/daemon/main-update.test.ts:53",   (startChecked: all five starts in the flaky test)
    +   "src/daemon/main-update.test.ts:100", …  67 starts in 24 files
    

    Test duration, Windows CI:

    2026-11-25 run 45570704146   20170 ms  (timed out)
    2026-11-25 run 45621989246   22666 ms  (timed out; the file's first test, 4 failed starts: 18451 ms)
    2026-11-27 run 46061249516   11054 ms  (main, passed)
    

    Root cause

    A defect in the test rig. src/daemon/main.ts:233-234 falls back to new PowerShellDirectoryAccessReader(...) when no directoryAccess is passed. On win32, prepareDataDirectory (src/daemon/connection-host.ts:70) then spawns PowerShell on every start. startChecked (main-update.test.ts:53) passes no reader. start in test-main.ts:49 passes a fake because of this exact cost, but 67 other starts do not. At 1–4.6 s per spawn on a loaded runner, five plus the polls pass 20 s. Inferred from CI durations (the same file runs in under 1 s on macOS); the Windows machine was unreachable to time PowerShell directly.

    Simplest fix

    Pass directoryAccess: new FakeDirectoryAccessReader({ entries: [], user: "S-1-5-21-1-2-3-1001" }) next to hostLoadProbe in the 67 starts. Tried mechanically (25 files, +111/−12):

    vitest run --project unit src/daemon/test-daemons-host-load.test.ts   → 2 passed
    vitest run --project unit <the 20 changed test files>                → 179 passed
    vitest run --project unit <helper users: main-worker-lock, main-start-daemon, agent-device> → 402 passed
    tsc --noEmit (src, packages/e2e)                                      → clean
    

    Alternatives rejected

    Risk

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 28, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 28, 2026
  6. self-assigned this
    on Nov 28, 2026
  7. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done: PR #1934 adds a fake directoryAccess reader to every test daemon start, so no test starts PowerShell on Windows. A guard test in test-daemons-host-load.test.ts fails on any start without one. Audit clean. Review round 1: 0 blocking findings, one note (the guard's file scan now runs twice). The PR is ready.

    Not done: merge.

    Findings: none blocking. #1914 and a main-stop.test.ts flake probably share this cause, per the triage report.

    Blocked on: fast-track: #1913 held: PR #1934 changes 302 lines, over 250; PR #1934 changes 25 files, over 8. The maintainer merges the PR, or removes fast-track.

    Written by an agent.

  8. added
    bug:blocked
    and removed
    bug:ready
    on Nov 28, 2026
  9. removed their assignment
    on Nov 28, 2026
  10. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1913 — PR #1934 held by the fast track (302 lines, 25 files); ready for the maintainer to merge
    Waiting: none
    Decided: none
    Asleep: 133 min

    Written by an agent.

  11. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Fixed by #1935, merged as 9457a80: no daemon a test starts runs PowerShell on Windows, the five in main-update.test.ts included. The duplicate fix #1934 is closed.

    Written by an agent.

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

    bug:blockedfast-trackflaky-test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions