Enhance GitHub GraphQL Rate Limit Handling and Token Security - #8273
Enhance GitHub GraphQL Rate Limit Handling and Token Security#8273pisum-sativum wants to merge 11 commits into
Conversation
…nt timeout on large repos
|
@pisum-sativum is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request effectively resolves critical issues related to GitHub GraphQL rate limits and enhances token security. The changes made, such as request deduplication and error handling, are crucial for maintaining the integrity of our API interactions. It's worth noting that similar past decisions focused on improving user experience through visually themed error responses, which highlights our commitment to both functionality and user experience. Thank you for your contributions, and I look forward to your feedback! |
|
@JhaSourav07 I have done the necessary changes kindly check and merge with appropriate labels. |
There was a problem hiding this comment.
Pull request overview
Improves GitHub API resiliency by adjusting retry/abort behavior and contribution-request coalescing to reduce duplicated calls and avoid leaking sensitive request details, while also tweaking CI analytics paging and reordering the socials registry.
Changes:
- Updates
fetchWithRetryerror/abort handling and adjusts contribution-fetch coalescing so abort signals don’t bypass deduplication. - Reduces CI Actions pagination depth for CI analytics fetches.
- Sorts the socials registry alphabetically at module initialization.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| services/github/ci-analytics.ts | Reduces Actions pagination (likely to lower API usage). |
| lib/github.ts | Changes abort/error behavior in retry logic and contribution request coalescing for better dedup + safer error surfaces. |
| app/generator/data/socials.ts | Sorts socials registry by display name (user-visible ordering change). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (didThrow) { | ||
| if (options.signal?.aborted) throw fetchError; | ||
| if (options.signal?.aborted) throw new Error('AbortError'); |
| return new Promise<ExtendedContributionData>((resolve, reject) => { | ||
| if (options.signal?.aborted) return reject(new Error('AbortError')); | ||
|
|
||
| const onAbort = () => reject(new Error('AbortError')); | ||
| options.signal?.addEventListener('abort', onAbort, { once: true }); | ||
|
|
| placeholder: 'e.g. https://huggingface.co/yourname', | ||
| }, | ||
| ] as Social[] | ||
| ).sort((a, b) => a.name.localeCompare(b.name)); |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
This is a solid improvement to our GraphQL rate limit handling and request cancellation logic! The way you're handling \AbortError\ and coalescing requests is very robust.
However, similar to PR #8274, it looks like this branch contains unrelated changes that were accidentally committed. Specifically, the changes to \�pp/generator/data/socials.ts\ and \services/github/ci-analytics.ts\ do not belong in this PR.
To fix this, please revert the changes to those files using \git restore\ or \git checkout\ so that this PR is focused entirely on the GitHub API rate limit and token handling.
Looking forward to getting this merged once the branch is cleaned up!
Label Justification:
- \level:advanced: Implementing complex request coalescing, abort controller logic, and rate-limit backoff across the API layer is an advanced task.
- \ ype:bug\ & \ ype:security: Prevents token exhaustion and handles API edge cases securely.
- \mentor:Aamod007: Assigned as required.
…te-limit # Conflicts: # lib/github.ts
|
🚨 Hey @pisum-sativum, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
… achievements) to main state
@Aamod007 I have done the necessary changes required but the CI is failing again and again I tried to fix it but I don't think so I can. Maybe after sometime will try ;( |
Aamod007
left a comment
There was a problem hiding this comment.
New commits address some of the previous concerns. The signal/abort refactoring in fetchGitHubContributions looks notably better — properly propagating abort signals through the coalesced promise pattern rather than ignoring them. The error message extraction (fetchError instanceof Error ? fetchError.message : String(fetchError)) is a good improvement too.
CI is still failing though. Please check the logs and fix whatever is causing the failures before we can approve.
Label justification:
- level:advanced — the async signal propagation + coalesced promise pattern is non-trivial, spans 4 files including github.ts which has complex retry/abort logic
- quality:clean — well-structured changes
- type:bug, type:security — rate limit error handling + token security
- mentor:Aamod007 — assigned
Aamod007
left a comment
There was a problem hiding this comment.
Re-reviewing: the only CI failure was Vercel authorization (not code-related). All code checks pass. The Vercel deploy auth is a repo-level config issue. Approving.
|
@Aamod007 @JhaSourav07 Kindly check and merge if possible with correct labels. |
@Aamod007 Do I need to make any changes which you stated ? |
|
@Aamod007 @JhaSourav07 Kindly merge this pr so that i can take up new issues since the bots is not allowing me to take up any more new issues . |
|
@Aamod007 @JhaSourav07 If no change is required then kindly check and merge. |
|
@Aamod007 @JhaSourav07 pls check and merge. |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
Aamod007
left a comment
There was a problem hiding this comment.
Nice improvement! Alphabetically sorting the socials dropdown makes the UI much more intuitive and user-friendly for people trying to find a specific platform. Approved!
|
@Aamod007 @JhaSourav07 Caan u pls merge this pr asap |
|
@Aamod007 @JhaSourav07 pls merge this pr asap |
|
@JhaSourav07 could you please merge all the PRs I've worked on? I've been requesting this for several days now but they are still pending. I would really appreciate it if you could review and merge them as soon as possible. Thank you! |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
|
@JhaSourav07 pls merge |
|
@JhaSourav07 Any update? |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
2 similar comments
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |



Description
Fixes #6239
This PR resolves critical issues related to GitHub GraphQL rate limit exhaustion and token exposure vulnerabilities.
Specific changes include:
lib/github.tswhere request deduplication was bypassed for requests providing anoptions.signal. The background cache-populating fetch is now properly decoupled from individual request abort signals, preventing duplicate GraphQL calls for concurrent same-user requests.TypeError) and converted them into generic errors. This guarantees thatRequestobjects, which contain theAuthorizationheader with the Personal Access Token (PAT), are stripped and never logged to serverless dashboards or exposed to clients.Pillar
Visual Preview
No visual changes. This PR strictly improves backend API resilience, rate limit handling, and token security.
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.