Skip to content

bug: Active users are dropped from leaderboard if live API wrapper fetch fails during sync #263

Description

@yashvi-3106

Description

In sync-leaderboard.js, when performing the daily stats sync, the script makes an external request to fetch live LeetCode stats for each active user. If the wrapper API fails (due to a rate limit HTTP 429, timeout, or DNS failure), the script skips that user:

// scripts/sync-leaderboard.js
const data = await fetchData(baseUrl + user.id);
if (!data) {
  console.log(`${user.name}: skipped (API error)`);
  return;
}

Because the execution return is premature, the user is completely omitted from the newly written overall.json. Consequently, the user disappears from the leaderboard until the next successful sync runs. This also corrupts delta calculations (e.g., treating them as [new] users when they reappear).

Expected Behavior

If fetching live data fails for an active user, the script should fall back to recycling their last known score and data structure from the cached overall map (historyMap), rather than dropping them.

Proposed Solution

Update sync-leaderboard.js to look up the user's previous data from historyMap as a fallback inside the fetchData failure block.

Metadata

Metadata

Assignees

Labels

BackendTask mainly involving backendlevel:intermediateIndicates the difficultytype:bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions