Severity
Critical — Makes the entire sync pipeline unreliable
Location
scripts/sync-leaderboard.js:14-15
Description
fetchData() terminates the entire Node process if any single user's API call fails:
async function fetchData(url) {
try {
const res = await axios.get(url);
return {
easySolved: res.data.easySolved || 0,
mediumSolved: res.data.mediumSolved || 0,
hardSolved: res.data.hardSolved || 0
};
} catch (err) {
console.error("API failed to respond: ", err.message);
process.exit(1); // kills everything
}
}
With 10+ users hitting a third-party API, transient failures are guaranteed. When
one user fails:
- All previously fetched data (other users) is lost
- CI iteration running at 300s intervals is wasted
- With continue-on-error: true, the failure is invisible
- No Axios timeout (default: 0 = infinite) means a hang kills the entire 6-hour run
Why It Matters
- The sync script generates all leaderboard data — it's the most critical function
- Third-party APIs are inherently unreliable
- A single rate-limited user means zero data for everyone that cycle
- No partial-results fallback
Fix
async function fetchData(url) {
try {
const res = await axios.get(url, { timeout: 15000 });
return {
easySolved: res.data.easySolved || 0,
mediumSolved: res.data.mediumSolved || 0,
hardSolved: res.data.hardSolved || 0
};
} catch (err) {
console.error(`API failed for ${url}: ${err.message}`);
return null; // signal failure without killing process
}
}
// In the loop:
if (data === null) {
console.log(`Skipping ${user.name} due to API error`);
continue;
}
Severity
Critical — Makes the entire sync pipeline unreliable
Location
scripts/sync-leaderboard.js:14-15
Description
fetchData() terminates the entire Node process if any single user's API call fails:
With 10+ users hitting a third-party API, transient failures are guaranteed. When
one user fails:
Why It Matters
Fix