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: key-set-fetcher.test.ts waits 50 ms of real time for a request to reach its server #1981
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.
src/ports/key-set-fetcher.test.ts:58-59 sleeps 50 ms and then asserts expect(received).toBe(true). On a loaded macOS host (15-minute load average 52, read five minutes later) the request had not arrived by then:
AssertionError: expected false to be true // Object.is equality src/ports/key-set-fetcher.test.ts:59:22
Seen once, in a run of all of src/ports; the file passed in the next run. Found while triaging #1979.
Seen on: the reporter's test output (a loaded macOS host). Not reproduced unmodified: 25 of 25 runs passed here at load average 42 to 53 on 12 cores.
The bug is in the test; the fetcher is correct. On bug/1981-repro, src/ports/key-set-fetcher.test.ts, "ends a request its server receives late and never answers when its signal aborts": the existing test, whose server now stops the process for 200 ms when the connection arrives, as a loaded host does. It fails every run (10 of 10) with the reported assertion:
pnpm exec vitest run --project unit src/ports/key-set-fetcher.test.ts
AssertionError: expected false to be true // Object.is equality
❯ src/ports/key-set-fetcher.test.ts:64:22 (line 59 on main)
Root cause
Defect in the test. src/ports/key-set-fetcher.test.ts:58 on main waits a fixed 50 ms for the request to reach the server, and line 59 asserts that it did. The connection and the request need several turns of the event loop the test shares with its server. When the process does not run for 50 ms in between, the timer fires first. Testing rule 5 keeps such a real-time bound out of unit tests. The 1 s wait at line 62 is not a second race: with it replaced by microtasks alone, the test passes, so abort() settles the fetch before any timer can fire.
Simplest fix
Wait for the request itself. A fetch that fails early still ends the wait, and line 59 then names the failure.
import{once}from"node:events";// replaces the 50 ms waitawaitPromise.race([once(serverasServer,"request"),settled]);
fix: 3 passed (3); vitest run --project unit src/ports → 438 passed | 11 skipped; pnpm typecheck clean
mutation: fetch without the signal → expected undefined to be 'AbortError'
mutation: throws before sending → expected false to be true
Alternatives rejected
A longer wait: still a race with host load.
Drop line 59: an abort before the connection would then pass too.
Risk
A fetch that neither sends nor settles now fails by vitest's 20 s timeout, not on line 59.
The 200 ms stop, kept as the regression case, adds 200 ms to the file.
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.
Activity
V3RON commentedon Nov 30, 2026
Reproduction
Seen on: the reporter's test output (a loaded macOS host). Not reproduced unmodified: 25 of 25 runs passed here at load average 42 to 53 on 12 cores.
The bug is in the test; the fetcher is correct. On
bug/1981-repro,src/ports/key-set-fetcher.test.ts, "ends a request its server receives late and never answers when its signal aborts": the existing test, whose server now stops the process for 200 ms when the connection arrives, as a loaded host does. It fails every run (10 of 10) with the reported assertion:Root cause
Defect in the test.
src/ports/key-set-fetcher.test.ts:58on main waits a fixed 50 ms for the request to reach the server, and line 59 asserts that it did. The connection and the request need several turns of the event loop the test shares with its server. When the process does not run for 50 ms in between, the timer fires first. Testing rule 5 keeps such a real-time bound out of unit tests. The 1 s wait at line 62 is not a second race: with it replaced by microtasks alone, the test passes, soabort()settles the fetch before any timer can fire.Simplest fix
Wait for the request itself. A fetch that fails early still ends the wait, and line 59 then names the failure.
Alternatives rejected
Risk
Fast track
Side findings
Written by an agent.
V3RON commentedon Nov 30, 2026
Delivery run
Merged: #1983 (#1981)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(ports): the key-set abort test waits for the request, not 50 ms (c…