Repository navigation
fix(pr-pipeline): round a Retry-After stop up so a short one is waited out - #17560
kyle-sexton wants to merge 2 commits into
Conversation
…d out classify stamped a Retry-After stop as floor(now) + retry-after. An answer late in a second got a stop that ended a few ms later, before observe re-read the clock to decide the resend, so waits() saw no stop and a read the client would have resent after one second failed the step instead. Main went red on this in run 44631001257. The Retry-After candidate now rounds the answer's time up, so the stop is always at least retry-after seconds out. Vectors use whole-second clocks, so no vector changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
…e ride-out test Move the regression test out of rate-guard.test.mjs, which it pushed over the 1000-line size check, into check-trusted-trigger.test.mjs, where it drives createGitHub on a latch clock that ticks 5 ms per read from 970 ms into a second: the old floor stamping fails it with the same 403 main saw, and the rounded-up stop passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e78593acf5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const nowSeconds = Math.floor(now / 1000); | ||
| const candidates = [ | ||
| retryAfter !== null ? [nowSeconds + retryAfter, "retry-after"] : null, | ||
| retryAfter !== null ? [Math.ceil(now / 1000) + retryAfter, "retry-after"] : null, |
There was a problem hiding this comment.
Account for rounding when checking the retry wait budget
When a response carries Retry-After: 60 and arrives between whole-second boundaries, rounding up makes the computed wait exceed the default 60,000 ms budget. For example, with now = 1700000000500, the new reset is 60,500 ms away, so createRateLimitLatch.waits() returns false and observe() fails the step instead of allowing retryServerErrors() to resend the read; the previous calculation allowed that retry. Preserve the conservative reset rounding, but account for its padding in the budget comparison so a delay equal to the configured budget remains retryable.
Useful? React with 👍 / 👎.
No related issue: main-red run 44631001257
Summary
Main went red in run 44631001257: "a read that rides out a short rate limit leaves the process green" in
check-trusted-trigger.test.mjsgot a 403 with retry-after 1, and instead of waiting the read failed the step (no call to it before 2026-11-19T22:51:44Z (retry-after); this step fails, logged at 22:51:44.010).The cause is a clock race in the rate guard, not test environment. The failing step's env listing has no
API_BUDGET_*variable, andwaitBudgetMs(rate-guard.mjs:98-101) can only raise the 60 s budget.classify(rate-guard.mjs:510-512) stamped a Retry-After stop asfloor(now / 1000) + retryAfter. An answer at x.99 s got a stop only a few ms ahead.observecapturesnowforclassify, awaits the body reads, then decides the resend withwaits(url)(rate-guard.mjs:845) on a freshnow(). Once the clock has crossed the second,until()returns null,waitsis false, and a read the client would have resent after a second fails the step.check-trusted-trigger.mjs:271and the guard loop (rate-guard.mjs:911) make the samewaitsdecision and miss the same way.Fix
The Retry-After candidate now rounds the answer's time up (
Math.ceil(now / 1000) + retryAfter), so the stop is always at least retry-after seconds out, as GitHub asks. Thex-ratelimit-resetand fallback paths are unchanged.rate-guard.vectors.jsonuses whole-second clocks, so no vector changes and the other ports keep parity.A regression test in
check-trusted-trigger.test.mjsdrivescreateGitHubon a latch clock that ticks 5 ms per read, starting 970 ms into a second.latchClockgainsstartandtickoptions for it. It sits beside the ride-out test because adding it torate-guard.test.mjscrossed the 1000-line size check.Verification
GitHubErrormain saw, and passes with the fix.node --testonrate-guard.test.mjs(167/167),check-trusted-trigger.test.mjs(486/486), andlog-api-budget.test.mjswithpr-merge/merge-job.test.mjsall pass....process.envspawn in these test files shares the cause: the race was in the guard, so any real-clock test that hits a short retry-after is covered by the code fix.Related
🤖 Generated with Claude Code
https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj