Repository navigation
fix(api): report remaining time in Retry-After - #1603
Merged
mgoldsborough merged 2 commits intoOct 7, 2026
Merged
Conversation
Contributor
QA Review: fix/1498-retry-afterScope: 6 files, +59/−11 · reviewed: Critical (must fix)None. Fix in-PR (apply mechanically — no adjudication essay expected)
Suggestions (optional)
What Looks Good
Body claims
Next step for the author: answer these by id (the pr-adjudicate flow). Applying r1f1/r1f2 with one line each is enough. machine record{
"kind": "review", "pr": 1603, "round": 1,
"reviewed": "25967370b4a2866964577fb76004b2bbc19abd5b", "delta_base": null,
"risk": "LOW", "stop_gate": "n/a",
"verdict": "Correct core; two mechanical cleanups; CI awaiting fork approval",
"findings": [
{"id": "r1f1", "bucket": "fix-in-pr", "file": "src/api/rate-limiter.ts", "line": 15,
"claim": "windowSeconds getter has no src caller after this change; only its own test reads it",
"evidence": "reproduced", "receipt": "grep -rn windowSeconds src/ -> only the definition",
"preconditions": null, "fix": "delete getter and the 'exposes windowSeconds' test", "scope": "core"},
{"id": "r1f2", "bucket": "fix-in-pr", "file": "docs/src/content/docs/config/environment.mdx", "line": 43,
"claim": "doc says the window is per identity, but the MCP limiter keys on identity plus grant kind",
"evidence": "reproduced", "receipt": "src/api/routes/mcp.ts:124 keyOf = `${identity.id}:${grant.kind}`",
"preconditions": null, "fix": "say \"that caller's\" window", "scope": "peripheral"},
{"id": "r1s1", "bucket": "suggestion", "file": "src/api/routes/hooks.ts", "line": 216,
"claim": "webhook 429 still sends a fixed Retry-After: 60",
"evidence": "reproduced", "receipt": "sed -n 214,217p src/api/routes/hooks.ts",
"preconditions": null, "fix": "use consumeWithRetryAfter in the hooks route", "scope": "peripheral"}
]
} |
Applies review findings r1f1 and r1f2 on NimbleBrainInc#1603.
Contributor
Adjudication: round 1
The three rate-limit test files pass (16, after dropping the machine record{"kind": "adjudication", "pr": 1603, "round": 1, "fixed_at": "37458c75923c9c00a86710e6a2c41053d474e58d",
"findings": [
{"id": "r1f1", "verdict": "accepted", "fixed_at": "37458c75"},
{"id": "r1f2", "verdict": "accepted", "fixed_at": "37458c75"},
{"id": "r1s1", "verdict": "split", "issue": 1649}
]} |
Contributor
|
Thanks for the contribution @Coding-Professional Follow up issue if you want to grab that too: #1649 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RequestRateLimiteruses a fixed window starting with a key's first request, butrequestRateLimitalways returned the full window inRetry-After. For a 60-second window, a request rejected 50 seconds in was told to wait another 60 seconds instead of 10. The class comment also incorrectly called this a sliding window.Change
Retry-After. Near the boundary, a rejected request receives1, not60; at the boundary, the next request starts a new window.consume(key): booleanunchanged for existing webhook callers. The middleware usesconsumeWithRetryAfter(key), which returnsnullwhen allowed or the retry delay when rejected.Coverage
Deterministic tests check the remaining delay halfway through the window, one millisecond before reset, and admission at reset. The middleware test checks the emitted header. Existing real-time header assertions now accept the valid 1–60 second range so they do not depend on machine speed.
Related issue
Closes #1498
Verification
bun test --no-env-file test/unit/rate-limiter.test.ts test/unit/api/rate-limit-middleware.test.ts test/integration/api/request-rate-limit.test.ts— 17 passed.cd docs && bun run build— 70 pages built; internal links valid.bun run verifywas attempted on Windows but stopped atcheck:web-tests: its script expects.bin/tsc, whereas Bun installstsc.exehere. A separate full unit run encountered Windows path/file-mode failures and stalled in an OAuth timer test. These are outside the changed files; Linux CI remains the full-suite check.Checklist
docs/for the API behavior change.bun run verifyand the relevant checks; noted the Windows limitations above.