Repository navigation
Conversation
Detect HTTP 403 primary rate limits alongside secondary ones, carry response headers on GitHubError, and honor x-ratelimit-reset for exact retry waits. Fixes devarshishimpi#175. Signed-off-by: bfs2021 <[email protected]>
There was a problem hiding this comment.
Codra Review
✅ Nothing to flag. Reviewed 3 files (158 changed lines) and found no issues worth raising.
Reviewed commit: 7f5c7c8fb9
ℹ️ About Codra in GitHub
Your team has set up Codra to review pull requests in this repo. Reviews are triggered when you:
- Open a pull request for review
- Mark a draft as ready
Every review posts a summary here. A clean pass also gets a 👍 on the pull request itself.
Owner
Owner
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
The GitHub API client retries secondary rate limits (403 +
"secondary rate limit"), HTTP 429, and 5xx errors, but not primary rate limits. GitHub returns HTTP 403 with body"API rate limit exceeded for installation ID ..."for primary limits, so those requests fail immediately and abort in-progress reviews. Fixes #175.Root cause
withRetryonly classified a 403 as retryable when the body contained"secondary rate limit". Primary rate-limit 403s fell through to the non-retryable path. Separately,GitHubErrordid not carry response headers, so thex-ratelimit-resetvalue needed to compute an exact wait was discarded byassertResponseOk.Fix
"rate limit exceeded"/"api rate limit"in the body) alongside secondary ones.GitHubError;assertResponseOknow passesresponse.headers.x-ratelimit-resetis present, waitMath.max(0, reset*1000 - now) + 1000; otherwise use the existing exponential backoff (2^attempt * 30sfor rate limits).Testing
packages/provider-github/test/http-rate-limit.spec.ts: 4 tests covering primary 403 retry-and-succeed, exactx-ratelimit-resetwait, backoff fallback, and header propagation throughassertResponseOk. Written red first (4 failures), green after the fix.npm test -w @codraoss/provider-github— 4/4 pass.npm run typecheck -w @codraoss/provider-github— pass.npx eslinton all changed files — pass.