Skip to content

[BUG] Severe API Timeout via Sequential O(N) GitHub Commits Fetching #3170

Description

@nyxsky404

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

  1. Log in with a highly active GitHub account (1000+ commits).
  2. Open the dashboard.
  3. The API route hangs while sequentially fetching 10 pages from GitHub.
  4. 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:

  1. The REST Search API is inherently slow and heavily rate-limited (30 req/min).
  2. 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.
  3. 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.

Metadata

Metadata

Assignees

Labels

gssoc:assignedGSSoC: Issue assigned to a contributor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions