Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Why

Main's Test workflow ("Run UI seam-contract + DOM tests") went red on a74742f (run 38335172993) and be0b1fa (run 38329767152). Both times the failure was the same test, "something drawn over the first lines (a sheet) hides them: nothing is seen until it goes, and a cover mid-dwell restarts it", which timed out after 5000 ms and then timed out again on retry.

The cause: the thread-pane tests in packages/inbox/seenOnSight.test.tsx waited in real time for the one-second dwell and the 250 ms recheck. The waits in the sheet test add up to about 4.9 s, so there was about 100 ms of room under bun's 5 s default. A slower runner went past it. On my machine, --timeout 4900 makes it fail every time. The ECONNREFUSED lines near it in the log come from other test files, not this one.

What changed (test only, no product change)

  • The DOM block runs on bun's fake timers (jest.useFakeTimers() in beforeEach, useRealTimers() in afterEach).
  • wait(ms) now advances the test's clock with jest.advanceTimersByTime(ms). Before and after that, it waits one setImmediate turn, which the fake timers do not replace, so fetch replies and effects can settle.
  • Every step and every assertion is the same. The cover-mid-dwell step is now exact: the dwell starts at the latest 250 ms after the sheet goes, the cover at +600 ms is noticed before the dwell can end, and the "not seen" check at +1450 ms fails if the dwell does not restart.

Proof

  • The file now runs in about 0.5 s. Before, it took about 26 s.
  • 40 runs in a row of DOM_TESTS=1 bun test packages/inbox/seenOnSight.test.tsx: all 22 tests passed each time.
  • 15 runs with every core busy (yes loops) and --timeout 2000: all passed.
  • The full DOM step, run exactly as CI runs it (252 files, --isolate): 1817 pass, 0 fail.
  • The tests still catch the bugs they are meant to catch. I broke the product code on purpose in three ways, one at a time:
    • Removed the "nothing drawn on top" check: the sheet test fails.
    • Kept a dwell running when the lines are hidden: the sheet test and the blur test fail.
    • Stopped the 250 ms recheck: the sheet test fails.

The thread-pane tests in seenOnSight.test.tsx waited in real time for the
one-second dwell and the 250 ms recheck. The sheet test's waits add up to
about 4.9 s against bun's 5 s default timeout, so on a loaded CI runner it
timed out (main runs 38335172993 and 38329767152). The tests now run on
bun's fake timers: wait() advances the test's clock, and setImmediate lets
fetch replies and effects settle between steps. Same steps, same assertions;
the file takes about 0.5 s instead of 26 s.
…ob timeout

afterEach puts real timers back in a finally, so fake timers never leak
into a later file. wait() notes that a real timer must never be awaited
under fake timers. The test job gets timeout-minutes: 45 (green runs take
16-19 minutes): bun's per-test timeout cannot fire under fake timers, so
a stuck await would otherwise idle until GitHub's 6-hour default.
@backnotprop
backnotprop merged commit 723b41c into main Oct 13, 2026
29 checks passed
@backnotprop
backnotprop deleted the fix/seen-on-sight-fake-timers branch October 13, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant