Skip to content

feat: handle GitHub API rate limits gracefully (closes #32)#55

Open
Ai-chan-0411 wants to merge 1 commit intoO2sa:mainfrom
Ai-chan-0411:feat/handle-rate-limits
Open

feat: handle GitHub API rate limits gracefully (closes #32)#55
Ai-chan-0411 wants to merge 1 commit intoO2sa:mainfrom
Ai-chan-0411:feat/handle-rate-limits

Conversation

@Ai-chan-0411
Copy link
Copy Markdown
Contributor

Summary

  • Adds RateLimitError class in lib/github.ts to detect GitHub's rate-limit responses (HTTP 403/429, secondary rate limits)
  • API route (/api/compare) now returns HTTP 429 with a clear error message and optional rateLimitReset timestamp when the rate limit is hit
  • Frontend shows an amber warning banner with a ⏳ icon and user-friendly message distinguishing rate-limit errors from other failures

Changes

  • lib/github.ts: Wrap GraphQL call to catch rate-limit errors and re-throw as RateLimitError
  • app/api/compare/route.ts: Handle RateLimitError separately, respond with 429 and reset time
  • app/page.tsx: Track isRateLimit state, render amber-styled message for rate limit vs red for other errors

Test plan

  • Compare two valid users → normal response
  • Simulate rate limit (exhaust token) → amber "⏳ Rate limit reached" message shown
  • Error clears on next comparison attempt

- Add RateLimitError class in lib/github.ts to detect 403/429 rate limit responses
- API route returns HTTP 429 with clear message and optional reset time
- Frontend shows amber warning with rate-limit-specific messaging
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

@Ai-chan-0411 is attempting to deploy a commit to the osama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

Thank you for the pull request! ✅

A maintainer will review this soon. Please be patient while we take a look. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant