Bug Description
fetchContributionsForAccount in src/app/api/metrics/contributions/route.ts uses a while (page <= 10) loop to paginate through the GitHub Search API using await fetch(). These requests are executed strictly sequentially.
GitHub's Search API has high latency (often 500ms–2s per request). For highly active users, the API route will make up to 10 sequential roundtrips. This takes 5 to 20 seconds, almost guaranteeing a 504 Gateway Timeout on standard Serverless limits (10s/15s). The dashboard metrics fail to load permanently for these power users.
Steps to Reproduce
- Log in with a highly active GitHub account (1000+ commits).
- Open the dashboard.
- The API route hangs while sequentially fetching 10 pages from GitHub.
- Observe a
504 Gateway Timeout from the serverless edge, rendering the dashboard unusable.
Affected Area
API Routes
Screenshots
No response
Browser & OS
No response
Environment
Production (devtrack.site)
Additional Context
Suggested Fix:
- The REST Search API is inherently slow and heavily rate-limited (30 req/min).
- Implement an initial fetch to get the
total_count, calculate the required pages, and use Promise.all() to fetch up to 3-4 pages concurrently to respect secondary rate limits.
- Long-term, migrate this specific metric fetching to the GitHub GraphQL API, which allows pulling deep contribution data across multiple repositories in a single roundtrip.
Bug Description
fetchContributionsForAccountinsrc/app/api/metrics/contributions/route.tsuses awhile (page <= 10)loop to paginate through the GitHub Search API usingawait fetch(). These requests are executed strictly sequentially.GitHub's Search API has high latency (often 500ms–2s per request). For highly active users, the API route will make up to 10 sequential roundtrips. This takes 5 to 20 seconds, almost guaranteeing a
504 Gateway Timeouton standard Serverless limits (10s/15s). The dashboard metrics fail to load permanently for these power users.Steps to Reproduce
504 Gateway Timeoutfrom the serverless edge, rendering the dashboard unusable.Affected Area
API Routes
Screenshots
No response
Browser & OS
No response
Environment
Production (devtrack.site)
Additional Context
Suggested Fix:
total_count, calculate the required pages, and usePromise.all()to fetch up to 3-4 pages concurrently to respect secondary rate limits.