Repository navigation
Description
What happens
services/bot-social/test/console_rate_limit_notice.test.ts pins the refusal's retry_after to [599, 600] in two tests: :25 (account burst) and :43 (address burst).
The product derives that number from the oldest attempt still inside the window:
services/bot-social/src/auth-limit.ts:23—windowMs: 10 * 60 * 1000services/bot-social/src/auth-limit.ts:87—retry_after: Math.max(1, Math.ceil((oldest + this.limits.windowMs - now) / 1000))
So the value is exactly ceil(600 - elapsed_s), where elapsed_s runs from the first attempt of the burst to the refused one. The >= 599 bound therefore leaves under two seconds for a burst that makes 6 HTTP round trips (account test: sign-up, five failed logins, the refused one) or 11 (address test), each of them hashing a password. Alone on a quiet machine that takes well under a second; with the suite's 411 *.test.ts files loading the machine it does not, and both tests fail while the product behaves exactly as specified.
Evidence (local readings, not CI)
On 0d18af72ce8f478be473b16533df4e807ee3222b, from a local extract of the tree:
- Whole suite (
npm test→node --import tsx --test test/*.test.ts, plus--test-concurrency=4because the default concurrency saturates the host):not ok 527andnot ok 528, reportingretry_after 598andretry_after 596, at:25:12and:43:12withERR_ASSERTION. Both are plain assertion failures — not crashes, not timeouts — and the other 1111 cases that had run by then were green. - The same file alone, three consecutive runs: 3/3 pass,
retry_after599 or 600 every time. So it is the parallel load, not the product. - Deterministic probe: replaying the account burst with a known stall between the first and the refused attempt yields
elapsed 6000 ms → 594andelapsed 3991 ms → 597, matchingceil(600 - elapsed_s)to the second. - No duplicate:
search/issues q=repo:ThinkFlowLab/FlyBot is:issue in:title rate limit→total_count 0.
Expected
Both tests pass whenever the product returns the specified refusal, however long the burst itself takes; only an actually wrong retry_after (wrong window, wrong rounding, wrong scope) should fail them.
Suggested fix (test-only, no product change)
Measure the burst's own elapsed time in the test and derive the lower bound from it, keeping the upper bound at 600 and leaving the console-string assertions ("Try again in about 10 minutes.") untouched:
const started = Date.now();
// ...the burst...
const elapsed = Date.now() - started;
const lowest = 600 - Math.ceil(elapsed / 1000) - 1;
assert.ok(
blocked.body.error.retry_after >= lowest && blocked.body.error.retry_after <= 600,
`retry_after ${blocked.body.error.retry_after} elapsed ${elapsed}`,
);A secondary option is to shrink the window through BOTSOCIAL_AUTH_RATE_LIMIT_WINDOW_SECONDS (src/auth-limit.ts:38) and assert the exact number, but both tests also assert the rendered sentence "Try again in about 10 minutes.", which is derived from the window, so that path needs the string assertions relaxed too and is the larger change.
Scope
Test-only. src/auth-limit.ts behaves correctly here: the refusal reports the true remaining wait.
Activity
Birfy commentedon Nov 30, 2026
Claimed for a test-only slice. Branch
dev/3468-rate-limit-drift-window, cut frommain(89e163ef).Scope: the two
retry_afterbounds inservices/bot-social/test/console_rate_limit_notice.test.ts(:25,:43) become derived from the burst's own elapsed time; the console-string assertions andsrc/auth-limit.tsstay untouched. Patch and local readings come from Services Dev; the push and PR are done by the Lead.Loosen the rate-limit notice tests to the burst's own duration
Birfy commentedon Nov 30, 2026
Landed on
mainasd57d6da41941822b9067cc579ad4944da3715eb3(squash of #3469, merged 07:29:49Z through the merge queue).Verified against the reviewed head
ed888b1f99e7bfa4923495523f508dc2061c4e0c: single parent89e163ef, tree8d620c66— the same tree the review recorded — with three files:services/bot-social/test/console_rate_limit_notice.test.ts+11/-3(blobc955c76b),docs/upstream/bot-social-files.json0/-6(blobe54e65e7),docs/upstream/migration-manifest.json+11/-1(blob5b0dbf82). All three blobs are byte-identical to the reviewed ones, and the squash message carriesRelated #3468with no closing keyword.Closing as completed: the notice tests now derive their lower bound from the burst's own duration instead of assuming the burst fits inside two seconds, and the migration manifest records the edited imported file so the provenance jobs stay green.
merge_groupon this tree reported success (18/18 at the reviewed head; the merge queue run ond57d6da4also completed success).