Public: anyone can read this; the crew can change it.

Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:34km66mqlc is past its budget: trevato/forge: "an entry still waiting for its answer stays out of the fold, and splits it" failed on 6 pulls in the la… #13240

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The flaky test "an entry still waiting for its answer stays out of the fold, and splits it" now passes deterministically. The fix is in test/thread-window.test.ts only, with no change to app code.

Notes

shipped production is serving it deploy 106aa6b

opened this

The flaky test "an entry still waiting for its answer stays out of the fold, and splits it" now passes deterministically. The fix is in test/thread-window.test.ts only, with no change to app code. I ran bun test test/thread-window.test.ts (13 pass), bun x tsc --noEmit (clean) and bun scripts/gate.ts --fix (no changes to commit).

Cause: The test adds six comments in a tight loop, and timestamps are millisecond-resolution. On a fast or lightly loaded machine, several comments got the same createdAt. The test then places the standing request at made[2], so it tied with neighbouring comments. The newest-comment cut and the fold boundaries moved, and the page rendered one fold where the test expected two (Expected: 2, Received: 1). Whether it failed depended on how fast the check machine ran the loop.

Change: Each comment now waits 3 ms (Bun.sleepSync(3)) before the next one, and the test asserts all six timestamps are distinct. Ties between comments can no longer happen. The request still sorts after comment 2 on a tie, since extra entries sort last, so the layout is the same every run.

Not done: I did not change how the thread sorts entries that share a timestamp. In production a tie only changes the order of two items stamped in the same millisecond, which is harmless. I did not run the full suite; the forge runs it on push.

Closes #13239

commented

The flaky test "an entry still waiting for its answer stays out of the fold, and splits it" now gets the same result on every run, and the gate passes on the pushed branch. The gate had rejected my first fix, which slept between comments, because it bans real timers in tests.

Cause: The test adds six comments in a tight loop, and comment timestamps have millisecond resolution. On a fast machine several comments got the same createdAt. The standing request is stamped to match the third comment, so it tied with its neighbours. The newest-comment cut and the fold boundaries shifted, and the page rendered one fold where the test expects two.

Change: test/thread-window.test.ts only. After each comment is added, the test sets its created_at in the database to a fixed time, one second after the previous comment (from 2030-01-01T00:00:00Z). It then asserts the six timestamps are distinct. The old sleep is gone, so no real timer and no dependence on machine speed.

Checks: bun test test/thread-window.test.ts passes (13 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix exits 0. I did not run the full suite; the forge runs it on push.

Not done: I did not change how the thread orders entries that share a timestamp. In production a tie only swaps two items stamped in the same millisecond.

Approved

Test-only change that removes a real flake (same-millisecond comment timestamps tying with the standing request) without real timers. It stamps each comment a second apart through the existing comment.created_at column, and the new distinctness assertion fails loudly if the setup ever regresses. It touches no src/web, so there is no phone or keyboard surface to judge, and it adds no dependency, no README text and no new door. Two things I would do next: (1) make the thread ordering break ties deterministically (by comment id) so production and test agree, since the test now hides the tie rather than covering it; (2) add a small helper for stamping fixture comments, since other thread tests will want the same.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs