Description
The scripts/fetch-student-info.js file collects a user's LeetCode submission history by fetching daily JSON snapshots from a data repository. It loops through a date range (default 365 days) and makes parallel fetch() calls via Promise.all().
The bug: If a user did not submit any solution on a particular day (e.g., weekends, holidays), the daily snapshot for that date does not exist. The current fetch() implementation treats a 404 response as a hard failure — the entire Promise.all() rejects, and the function returns an empty history array. This means if a user skipped even one day in the past year, their entire history graph shows as empty.
Additionally, the script fires 100+ concurrent fetch requests in a single Promise.all() — this will trigger rate limiting on raw.githubusercontent.com and cause all requests to fail.
Proposed Solution
Fix 1 — Missing days should be skipped, not fatal:
- Replace
Promise.all() with Promise.allSettled() so individual 404 failures don't reject the entire batch.
- For each settled promise, only include the result if it was fulfilled and returned valid data.
- Log skipped dates at
console.warn level (not error) for observability.
Fix 2 — Reduce concurrency to avoid rate limiting:
- Implement a concurrency limiter — process fetches in chunks of 10-15 at a time instead of 100+.
- Add a small delay (200-300ms) between chunks to be respectful to the upstream API.
Fix 3 — Validate response status explicitly:
- Before parsing JSON, check
response.ok. If !response.ok, treat as "no data for this day" (not an error) and skip the date.
Acceptance Criteria
Affected Files
scripts/fetch-student-info.js
Description
The
scripts/fetch-student-info.jsfile collects a user's LeetCode submission history by fetching daily JSON snapshots from a data repository. It loops through a date range (default 365 days) and makes parallelfetch()calls viaPromise.all().The bug: If a user did not submit any solution on a particular day (e.g., weekends, holidays), the daily snapshot for that date does not exist. The current
fetch()implementation treats a 404 response as a hard failure — the entirePromise.all()rejects, and the function returns an empty history array. This means if a user skipped even one day in the past year, their entire history graph shows as empty.Additionally, the script fires 100+ concurrent fetch requests in a single
Promise.all()— this will trigger rate limiting onraw.githubusercontent.comand cause all requests to fail.Proposed Solution
Fix 1 — Missing days should be skipped, not fatal:
Promise.all()withPromise.allSettled()so individual 404 failures don't reject the entire batch.console.warnlevel (not error) for observability.Fix 2 — Reduce concurrency to avoid rate limiting:
Fix 3 — Validate response status explicitly:
response.ok. If!response.ok, treat as "no data for this day" (not an error) and skip the date.Acceptance Criteria
Affected Files
scripts/fetch-student-info.js