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
test(cli): waitFor's fixed 250 ms wall-clock deadline makes 373 TUI assertions flaky under CI load #2221
CI failed on PR #2208, a documentation-only change whose diff touches nothing but two files under docs/eval/. The failing job was test_workspaces, in the [cli] workspace:
✖ marks an inherited running Bash card detached after rewind (262.565832ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
false !== true
at waitFor (packages/cli/dist/__tests__/tui-terminal-mock.js:115:12)
at TestContext.<anonymous> (packages/cli/dist/__tests__/pi-tui-runner.test.js:4385:9)
Re-running the same job on the same commit passed with no other change. main was green at the time.
Root cause
waitFor polls a predicate against a hard-coded 250 ms wall-clock budget:
The reported test duration was 262.6 ms — the assertion fired essentially the moment the budget expired, not because the predicate was ever going to be false. The budget is a fixed wall-clock number, so it does not scale with a loaded runner, and the failure mode when it expires is an opaque false !== true rather than a description of what was being waited on.
waitFor is a shared helper with 373 call sites across pi-tui-runner.test.ts, cli-goal-continuation.test.ts, runtime-bootstrap.test.ts, and slash-command-completion.test.ts. Any of them can fail this way; this issue reports the one that happened to lose the race.
Why it matters
The failure is indistinguishable from a real regression at the point of reading CI: a docs-only PR showed a red test_workspaces, and telling the two apart required pulling the job log and re-running. That cost is paid by every PR that hits it.
Suggested direction
Not prescribing a fix, but the constraints seem to be:
The budget should scale with the environment rather than being a fixed 250 ms — an env-var override honoured in CI, or a multiplier, would remove the load sensitivity without slowing local runs.
The expiry assertion should name what it was waiting for. waitFor currently receives only a predicate, so it has nothing to report; taking a description argument would turn false !== true into an actionable message across all 373 call sites.
Repro
Not deterministically reproducible by design — it is a load-dependent race. Observed on test_workspaces in run 30986889078; the re-run of the same job on the same commit passed.
Same root cause, second workspace: packages/headless
Hit this on PR #2227, a renderer-only change (7 files, all under packages/ui; zero headless files touched). The failing job was test_headless, not test_workspaces:
✖ does not report deadline settlement after normal completion already claimed the terminal state (3138ms)
harbor-cell.test.ts:1285 passes a fixed settleAfterMs: 1_000 and then asserts result.settledByDeadline === false — i.e. it asserts that normal completion wins a race against a 1 s wall-clock budget. The run took 3138 ms, so on a loaded runner the deadline latched first and the assertion reported the opposite of what it was written to check. Re-running the same job on the same commit passed with no other change.
This is not waitFor, so it is not fixed by whatever replaces the 250 ms budget in tui-terminal-mock.ts — but it is the same defect shape: a test encodes a fixed wall-clock number as if it were a logical ordering guarantee. Worth noting here so a fix scopes to the pattern rather than to the one helper.
Two other data points that make the pattern worth a sweep rather than a point fix:
The sibling test right below it (does not start a continuation turn after the settlement deadline latches, line 1308) wraps its run in withTimeout, i.e. the file already contains both the fragile and the guarded shape.
Suggested scope: audit for fixed millisecond budgets that gate an assertion about ordering, and make the ordering explicit (deterministic clock, injected settle signal, or a barrier) instead of widening the number.
Activity
Astro-Han commentedon Aug 5, 2026
Same root cause, second workspace:
packages/headlessHit this on PR #2227, a renderer-only change (7 files, all under
packages/ui; zero headless files touched). The failing job wastest_headless, nottest_workspaces:harbor-cell.test.ts:1285passes a fixedsettleAfterMs: 1_000and then assertsresult.settledByDeadline === false— i.e. it asserts that normal completion wins a race against a 1 s wall-clock budget. The run took 3138 ms, so on a loaded runner the deadline latched first and the assertion reported the opposite of what it was written to check. Re-running the same job on the same commit passed with no other change.This is not
waitFor, so it is not fixed by whatever replaces the 250 ms budget intui-terminal-mock.ts— but it is the same defect shape: a test encodes a fixed wall-clock number as if it were a logical ordering guarantee. Worth noting here so a fix scopes to the pattern rather than to the one helper.Two other data points that make the pattern worth a sweep rather than a point fix:
does not start a continuation turn after the settlement deadline latches, line 1308) wraps its run inwithTimeout, i.e. the file already contains both the fragile and the guarded shape.Suggested scope: audit for fixed millisecond budgets that gate an assertion about ordering, and make the ordering explicit (deterministic clock, injected settle signal, or a barrier) instead of widening the number.
Benjamin-eecs commentedon Aug 6, 2026
Taking this.
refactor(test): give predicate polling one implementation