Repository navigation
gh-prs-merge: back off secondary rate limits instead of retrying every 65 s - #262
Merged
Merged
Conversation
…y 65 s
When `gh` was refused but no `gh api rate_limit` bucket was empty (a
secondary/abuse limit), parseRateLimitReset invented "now + 60 s". Every
retry then printed "rate limit exhausted; waiting until it resets ... (in 2m)"
and hit GitHub again 65 s later, which keeps a secondary penalty alive: the
reset crept forward a minute per line and the sweep never resumed.
- parseRateLimitReset returns undefined when no bucket is dry.
- Secondary limits back off 1, 2, 4, 8 m (streak shared across calls, reset
on the first success) and throw RateLimitError once the next step is past
--rate-wait, the same as an out-of-budget primary reset.
- Notices say "secondary rate limit" rather than "exhausted", and short
waits print as seconds ("65s", not "2m").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ThreatCrush Security Scan41 finding(s) HIGH/CRITICAL: 15 | MEDIUM: 12 | LOW: 14
Snippets are redacted; ThreatCrush never prints matched credential material. |
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
A sweep logged this every ~66 s and never resumed, even though
gh api rate_limitshowed core 4747/5000 and graphql 3758/5000:The refusal was a secondary (abuse) limit. With no bucket at
remaining: 0,parseRateLimitResetfell back to "now + 60 s", so every retry hit GitHub again 65 s later. Each refused call keeps a secondary penalty alive.Fix
parseRateLimitResetreturnsundefinedwhen no bucket is empty.--rate-wait, it throwsRateLimitError, the same as an out-of-budget primary reset, so the scope is marked FAILED instead of hanging.Tests
test/prs-merge.test.ts: 61/61 pass, including the new back-off, give-up and format cases.tsc --noEmitis clean.test/forwardemail.test.tsfails on its own and is untouched here.🤖 Generated with Claude Code