Skip to content

fix(sync): fallback to historyMap on API fetch failure (#263)#271

Open
yashvi-3106 wants to merge 1 commit into
codepvg:mainfrom
yashvi-3106:feature/api-error-fallback
Open

fix(sync): fallback to historyMap on API fetch failure (#263)#271
yashvi-3106 wants to merge 1 commit into
codepvg:mainfrom
yashvi-3106:feature/api-error-fallback

Conversation

@yashvi-3106

Copy link
Copy Markdown
Contributor

Description

This PR resolves issue #263 where active users were being dropped entirely from the leaderboard when external API wrapper fetches failed (due to rate limiting, network timeouts, or DNS failures).

Linked Issue

Fixes #263

Changes Made

  • Updated the daily fetch loop in scripts/sync-leaderboard.js to look up the user's cached records from historyMap when fetchData fails instead of logging and returning prematurely.
  • Recycles the user's last known stats (easySolved, mediumSolved, hardSolved, score, etc.) if available.
  • Skips the user only if no historical cached record is available.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Note: Tested using a mock environment by simulating API timeouts/rate-limit failures for test users and verifying that the daily sync recycled their previous overall data and scores correctly without dropping them.

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

@yashvi-3106

Copy link
Copy Markdown
Contributor Author

@jagdish-15 you can review it!

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this branch contains a few commits from your previous PR.

Could you cherry-pick just the commit related to this issue and then force-push the branch again? That'll keep this PR focused and make it easier to review.

@yashvi-3106 yashvi-3106 force-pushed the feature/api-error-fallback branch from c5ce622 to 83ea143 Compare July 1, 2026 16:55
@yashvi-3106

Copy link
Copy Markdown
Contributor Author

@jagdish-15 you can review it now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants