fix: robust GraphQL rate limit retry handling #916#917
Open
jaiyankargupta wants to merge 1 commit into
Open
Conversation
- Upgrade retry logic from a single attempt to a while loop - Properly check for !empty($decoded->errors) on retries - Exhaust all available tokens in the pool during rate limits before failing
Contributor
There was a problem hiding this comment.
Pull request overview
Improves resiliency of GraphQL contribution-graph fetching by retrying failed/invalid responses across multiple tokens, aiming to correctly surface the “rate-limited” error card instead of a generic contributions failure when tokens are exhausted.
Changes:
- Replace single retry with a loop to allow multiple retry attempts and token rotation.
- Ensure GraphQL error payloads (including rate-limit errors) are considered “invalid” and retried/handled.
- Add retry attempt logging and a retry cap to avoid infinite loops.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
Hey folks
Fixes #916
I noticed an issue where the streak card would occasionally throw the generic
"Failed to retrieve contributions. This is likely a GitHub API issue."error instead of correctly displaying the "We are being rate-limited" card when tokens ran out.After digging into it, I found that when the GraphQL API hits a rate limit and the code does its retry attempt, the logic was accidentally swallowing the rate limit error because it missed an
!empty($decoded->errors)check. Since the error slipped through, the exhausted token stayed in the pool and the application eventually crashed with that 500 error.I've fixed this up by:
whileloop so we can actually cycle through multiple backup tokens if needed.This should make the token rotation way more bulletproof when rate limits get tight. Let me know if you need anything else to get this merged!
Type of change
How Has This Been Tested?
composer testChecklist:
Screenshots
(N/A - backend logic fix only)