Repository navigation
fix: show a rate limit message when the GitHub or GitLab API limit is reached - #43
Merged
Merged
Conversation
Collaborator
|
LGTM! Thanks for the clean fix and comprehensive tests @rishiraj38. Checking both the repo and branch responses avoids the silent empty-branch bug, and omitting the client-side PAT token was the right security decision for a public Vite bundle. Merging now! |
Contributor
|
Hi @codxbrexx , I also came across your recent work reviewing PRs in MetaCall Launchpad, particularly the rate-limit handling improvements. I'm interested in getting involved with MetaSSR and would appreciate your suggestions on where I could start contributing. |
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
When the unauthenticated GitHub or GitLab API rate limit is reached, the Deploy Repository page now says so instead of showing the generic "GitHub API error." / "GitLab API error.".
A small
rateLimitMessagehelper treats GitHub's 403 withX-RateLimit-Remaining: 0and any 429 (GitLab, or GitHub's secondary limit) as a rate limit. It readsX-RateLimit-Reset/RateLimit-Reset(orRetry-After) to show when to try again, for example "GitHub API rate limit reached. Try again after 05:56 PM.", and falls back to "Try again later." when there's no reset header. Both the repository request and the branches request are checked, so a limited branches call no longer quietly turns into an empty branch list. 404 still shows "Repository not found." and other errors keep the existing message.Notes:
VITE_*variable is compiled into the public bundle, so a GitHub PAT there is visible to anyone who loads the page, and the app doesn't have a GitHub/GitLab OAuth session to reuse. If you want authenticated requests, a FaaS-side proxy seems safer.RateLimit-ResetinAccess-Control-Expose-Headers, so in the browser the GitLab message usually ends with "Try again later." GitHub exposesX-RateLimit-Reset, so the GitHub message shows the time.Fixes #38
Type of Change
fix:Bug fix (non-breaking change which fixes an issue)feat:New feature (non-breaking change which adds functionality)refactor:Code refactor (no functional changes, no API changes)docs:Documentation updatetest:Adding or updating testschore:Maintenance (CI, dependencies, tooling)Screenshots / Recordings
API responses intercepted with a Playwright route (GitHub: 403 +
x-ratelimit-remaining: 0, GitLab: 429).Checklist
npm run unitandnpm run test).npm run lint).fix: resolve login redirect).npm run unitpasses (142 tests, including 5 new ones indeploy_repository_page_test.tsxcovering a GitHub 403 limit, a limited branches request, a non-rate-limit 403, a GitLab 429 and a 404). I didn't run the Playwright suite (npm run test).format:check,typecheckandbuildalso pass.