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

Tests wait for a signal, not a clock: a ratchet on fixed sleeps in test/ #14321

shipped production is serving it opened this has it

Landed in pull #14358 · 2 runs · run

opened this

Fixed real-time waits make tests slow and flaky. test/ has 764 await Bun.sleep(<number>) calls in 392 files, plus 90 setTimeout(resolve, <number>) waits in 62 files. The worst files are release-prove (12), crew-early (10), my-shells (9), flake (8) and drill-weekly (8). Today scripts/flake.ts finds a flake only after it happens; a static check would stop new ones before merge.

The idea comes from the no-fixed-sleep rule in interfere-inc/landmines (MIT, Oxlint plugin). We will not add it as a dependency: it needs Node and Oxlint, and the forge has one gate.

Change: add scripts/test_honesty.ts, imported by scripts/gate.ts. It counts fixed numeric waits per test file and compares the counts to a committed allowance file (same pattern as docs/design/size-budget.json). A file over its allowance fails the gate with the message: "await the operation or an event it emits instead of a fixed delay". A file under its allowance also fails until the allowance is lowered, so the list only shrinks. FORGE_SLEEP_WRITE=1 regenerates the file.

Also count mock.module( (3 today) and test retry: / raised timeout: (5 today) with the same allowance.

Done when: the gate runs the check in pull checks and on main, the allowance file matches today's counts, and a test adding one new await Bun.sleep(50) fails the gate.

Not in scope: landmines' no-comments and no-explicit-return-types. They contradict how the forge documents its code.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs