Fix graph ql api rate limit#632
Conversation
|
@Ayush4958 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
👋 Hey @Ayush4958, welcome to CommitPulse! 🎉 Thanks for opening your first pull request — this is a big deal and we appreciate the effort! While you wait for a review, please double-check:
A maintainer will review your PR shortly. Hang tight! 🚀 |
|
hi @JhaSourav07 , PR is ready for review thanks |
There was a problem hiding this comment.
Pull request overview
Adds explicit GitHub API rate-limit handling and user-facing feedback for the streak badge, alongside a small dashboard UI fix and cleanup in the recent-searches hook.
Changes:
- Implement rate-limit detection/backoff in
fetchWithRetryand surface a consistent rate-limit error from GitHub fetch helpers. - Render a dedicated “rate limited” SVG (HTTP 429) from
/api/streakwhen rate limits are hit. - Fix a Tailwind className concatenation issue in the dashboard skeleton loader and simplify recent-searches localStorage handling.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/svg/generator.ts | Adds generateRateLimitSVG for a dedicated rate-limit error badge. |
| lib/github.ts | Extends retry logic to detect rate limiting and throws a dedicated rate-limit error from GitHub fetch functions. |
| hooks/useRecentSearches.ts | Removes standalone storage helpers; storage interactions are handled inline in the hook. |
| components/dashboard/StatsCardSkeleton.tsx | Fixes a missing space in className to restore intended styling. |
| app/api/streak/route.ts | Detects rate-limit failures and returns a 429 response with the new rate-limit SVG + no-cache headers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Use retry-after if provided, else exponential backoff | ||
| const delay = retryAfter | ||
| ? parseInt(retryAfter, 10) * 1000 | ||
| : BASE_DELAY_MS * Math.pow(2, attempt); |
| if (res.status === 403 && res.headers.get('x-ratelimit-remaining') === '0') { | ||
| throw new Error('API Rate Limit Exceeded'); | ||
| } | ||
| if (res.status === 429) { | ||
| throw new Error('API Rate Limit Exceeded'); |
| // Check for rate limit headers | ||
| const retryAfter = res.headers.get('retry-after'); | ||
| const isRateLimited = | ||
| res.status === 429 || (res.status === 403 && res.headers.get('x-ratelimit-remaining') === '0'); | ||
|
|
| const isRateLimit = message.toLowerCase().includes('rate limit'); | ||
| if (isRateLimit) { | ||
| const svg = generateRateLimitSVG(errBg, errAccent, errText, errRadius, errSpeed); | ||
| return new NextResponse(svg, { | ||
| status: 429, |
| export function generateRateLimitSVG( | ||
| bg: string, | ||
| accent: string, | ||
| text: string, | ||
| radius: number, | ||
| speed: string = '8s' | ||
| ): string { |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
@Ayush4958 do fixes according to Copilot suggestions. |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
1 similar comment
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Ohkk I will be making changes accordingly to the feedback |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
2 similar comments
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
🚨 Hey @Ayush4958, 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 |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
b3624fc to
53844f6
Compare
53844f6 to
35b11e9
Compare
Description
I had created a proper backoff and user-facing communication for GitHub API rate limits and some additional things I encountered :- fixes a UI bug on the dashboard for loading screen, and resolves all outstanding ESLint warnings.
Fixes #523
Pillar
Visual Preview
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.