Bug Report: GitHub API Called on Every Component Mount Causes Rate Limit Errors
Description
The User Profile page fetches live GitHub contribution data (commits, PRs, stars)
from the GitHub REST API every time the component mounts. GitHub's unauthenticated
API allows only 60 requests per hour per IP. In a shared network environment
(office, university campus) or when multiple users visit profile pages in quick
succession, the app exhausts the GitHub API rate limit. All subsequent users
see empty contribution graphs or an error state.
Steps to Reproduce
- Open the DevPath User Profile page for any GitHub-connected user.
- Refresh the page 60 times in under 1 hour (or simulate with a script).
- Observe the 61st request returns HTTP 403 with
X-RateLimit-Remaining: 0.
- All profile pages show empty contribution data until the hourly window resets.
Root Cause
The GitHub API call is made in a useEffect with no SWR/React Query caching,
no server-side caching, and no authenticated token to use the higher 5,000
req/hour limit.
Impact
The platform becomes degraded for all users on shared networks during peak
usage periods, which is precisely when a developer community platform sees
the most traffic.
Proposed Fix
Cache GitHub data server-side in Firestore with a 1-hour TTL:
// app/api/github-stats/route.ts
export async function GET(req: Request) {
const { username } = Object.fromEntries(new URL(req.url).searchParams);
const cacheDoc = await db.collection("github_cache").doc(username).get();
if (cacheDoc.exists && Date.now() - cacheDoc.data()!.fetchedAt < 3600_000) {
return Response.json(cacheDoc.data()!.stats);
}
const stats = await fetchGitHubStats(username, process.env.GITHUB_TOKEN);
await db.collection("github_cache").doc(username).set({ stats, fetchedAt: Date.now() });
return Response.json(stats);
}
Bug Report: GitHub API Called on Every Component Mount Causes Rate Limit Errors
Description
The User Profile page fetches live GitHub contribution data (commits, PRs, stars)
from the GitHub REST API every time the component mounts. GitHub's unauthenticated
API allows only 60 requests per hour per IP. In a shared network environment
(office, university campus) or when multiple users visit profile pages in quick
succession, the app exhausts the GitHub API rate limit. All subsequent users
see empty contribution graphs or an error state.
Steps to Reproduce
X-RateLimit-Remaining: 0.Root Cause
The GitHub API call is made in a
useEffectwith no SWR/React Query caching,no server-side caching, and no authenticated token to use the higher 5,000
req/hour limit.
Impact
The platform becomes degraded for all users on shared networks during peak
usage periods, which is precisely when a developer community platform sees
the most traffic.
Proposed Fix
Cache GitHub data server-side in Firestore with a 1-hour TTL: