feat(fetch): rate-limit backoff + enable auto-fetch by default (5min)#8
Merged
Conversation
Make background auto-fetch safe to have on by default. The active+visible tab is the only one that fetches, so at 5min that's ~12 API-bucket calls/hr (PR list + avatars) - a rounding error against GitHub's 5000/hr and GitLab's per-minute limits. git fetch itself rides the git protocol, a separate, effectively-unlimited bucket. The realistic failure mode is a secondary/abuse limit (GitHub 403 + Retry-After, GitLab 429), where retrying on schedule can prolong the block. So backgroundFetch and refreshPrs now recognise a rate-limit error (isRateLimited) and pause the loop until it clears (rateLimitBackoffMs honours an explicit retry-after hint, else 15min), toasting once on entry. Foreground/user-initiated ops are never gated by the backoff. Default interval flips 0 -> 5min; users who explicitly chose "Off" keep it (0 is stored), so only never-configured users get the new default.
|
🎉 This PR is included in version 0.30.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
What
Makes background auto-fetch safe to ship on by default, per the rate-limit analysis.
Rate-limit reality
gh pr list/glab mr listand avatar lookups (avatars are disk-cached w/ TTL).Changes
src/util.ts+RepoView.tsx):backgroundFetchandrefreshPrsrecognise a provider rate-limit error (isRateLimited) and pause the background loop until it clears (rateLimitBackoffMshonours an explicitretry-afterhint, clamped 30s..1h, else 15min). Toasts once on entering backoff. Foreground / user-initiated ops are never gated. This is the piece that stops on-schedule retries from prolonging a secondary limit.storage.ts): users who explicitly picked "Off" have0stored and keep it; only never-configured users get the new default.Notes / limits
ureqpath is a possible future refinement.Verify
isRateLimited(GitHub primary/secondary + GitLab 429; not plain 403/network) andrateLimitBackoffMs(retry-after parse + clamps + fallback) - 4 testshttps://claude.ai/code/session_01RVF5LSdTyciWKY1k5sedU8