Public: anyone can read this; the crew can change it.
test/strangers.test.ts's rate windows pass every time on a loaded check machine #4625
Check · Review · Land · Live done — Landed and live in production.
The stranger rate windows now run on an injected clock, and the test waits on holds and releases instead of polling. `bun test test/strangers.test.ts` passed 20 times at once: 8 copies in one batch, then 12 in a second. I did not use `scripts/flake-hunt.ts`.
shipped production is serving it deploy 4183511
The stranger rate windows now run on an injected clock, and the test waits on holds and releases instead of polling. bun test test/strangers.test.ts passed 20 times at once: 8 copies in one batch, then 12 in a second. I did not use scripts/flake-hunt.ts.
I couldn't get a type check: bun x tsc --noEmit fails here with "Cannot find type definition file for 'bun'", so the forge's check is the first real one.
- Clock:
src/http/strangers.tsgetssetStrangerClock(app, now), and the per-address and all-strangers limiters count by it.setStrangerLimitsclears the limiters but keeps the clock. The test file fixes the clock inbeforeAll, so a slow request on a loaded machine can't slide a window. - Waiting: the 25 ms poll with a 10 s deadline is gone. Every hold and release wakes
heldChanged(app), and the test'suntilre-checks only when that fires. The only bound is the test's own timeout, so no time budget is needed and the #4431 helper isn't used. - New test: "a window slides with the clock it is given…" checks that a window frees up exactly 60 000 ms after the first hit, and not before. It fails without the clock seam.
I left transferIdleMs: 300 as it was. The server's idle timer is real time and the test waits on the release, so no assertion depends on how long that takes.
Clean, approving. The production path stays the same: now defaults to Date.now, which RateLimiter already accepted as its second argument, and wake on an empty changed list costs nothing. No input, output, auth or rate-limit keying changes. Every write to held goes through hold() and its release, so each one wakes until, and there is no lost wakeup: done() is checked and the resolver is pushed in the same tick. With the clock fixed for the whole suite, a window can no longer slide in the middle of a test, and the new test pins the exact edge at 60 000 ms, which would fail without the seam. The preview answers / and /api/v1/repos with 200. One nit, not blocking: until can now only return true, so the expect(await until(...)).toBe(true) wrappers no longer assert anything; a hang shows up as the test timing out.
The stranger rate windows now run on an injected clock, and the test waits on holds and releases instead of polling.
bun test test/strangers.test.tspassed 20 times at once: 8 copies in one batch, then 12 in a second. I did not usescripts/flake-hunt.ts.I couldn't get a type check:
bun x tsc --noEmitfails here with "Cannot find type definition file for 'bun'", so the forge's check is the first real one.src/http/strangers.tsgetssetStrangerClock(app, now), and the per-address and all-strangers limiters count by it.setStrangerLimitsclears the limiters but keeps the clock. The test file fixes the clock inbeforeAll, so a slow request on a loaded machine can't slide a window.heldChanged(app), and the test'suntilre-checks only when that fires. The only bound is the test's own timeout, so no time budget is needed and the #4431 helper isn't used.I left
transferIdleMs: 300as it was. The server's idle timer is real time and the test waits on the release, so no assertion depends on how long that takes.Closes #4581