feat(cache): serve stale metrics on GitHub rate limits#2439
feat(cache): serve stale metrics on GitHub rate limits#2439bhavyajain0810 wants to merge 1 commit into
Conversation
GSSoC Label Checklist 🏷️@Umbrella-io — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
CI status noteThe two failing Playwright checks appear unrelated to the changes in this PR. E2E smoke testThe failing test is: Playwright reports a strict-mode violation because: matches two existing elements: the longest-streak card and its information button. The same failure occurred across retries, while the other 46 smoke tests passed. Visual regressionThe visual-regression job failed in these existing UI scenarios: The public-profile test timed out while waiting for the expected profile heading. Neither these pages nor their visual tests are modified by this PR. This PR only changes:
All relevant validation is passing, including build, lint, type-check, test coverage, dependency audit, environment security checks, and the focused cache and pinned-repository tests. Could you please review or rerun these unrelated Playwright failures? |
Summary
Adds stale-cache fallback support for GitHub-backed metrics so previously successful data can still be returned when GitHub temporarily rate-limits a refresh. The pinned repositories endpoint now uses the shared cache and centralized GitHub GraphQL handling while preserving authentication and non-rate-limit error behavior.
Closes #1930
Type of Change
What Changed
src/lib/metrics-cache.tswith an optional stale-cache layer, configurable stale-grace period, and error predicate for controlled fallback.src/app/api/metrics/pinned-repos/route.tsto usewithMetricsCache, cache-bypass handling, and the centralizedgithubGraphQLhelper.test/metrics-cache.test.tsfor stale fallback, unrelated errors, explicit cache bypass, and deletion of stale entries.How to Test
Run the focused lint checks:
Run the relevant tests:
npm test -- test/metrics-cache.test.ts test/pinned-repos.test.tsRun TypeScript validation:
Expected result:
tsc --noEmitcompletes without TypeScript errors.Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Additional Context