Skip to content

fix: prevent process.exit(1) on single user API failure (#61)#128

Merged
jagdish-15 merged 1 commit into
codepvg:mainfrom
rishab11250:fix/prevent-process-exit-on-api-failure-issue61
Jun 8, 2026
Merged

fix: prevent process.exit(1) on single user API failure (#61)#128
jagdish-15 merged 1 commit into
codepvg:mainfrom
rishab11250:fix/prevent-process-exit-on-api-failure-issue61

Conversation

@rishab11250
Copy link
Copy Markdown
Contributor

Description

Prevents process.exit(1) when a single user's LeetCode API call fails. Previously, one transient API failure would kill the entire sync cycle — losing all previously fetched data for other users. Now, failed users are logged and skipped, and syncing continues for the remaining users.

Additionally adds a 15-second axios timeout (default is 0 = infinite) to prevent a hanging request from silently destroying the entire 6-hour CI run.

Linked Issue

Fixes #61

Changes Made

  • Added { timeout: 15000 } to axios.get() call — prevents infinite hangs on unresponsive API
  • Changed process.exit(1) to return null on API failure — keeps the process alive
  • Improved error message to include the failing URL — easier debugging
  • Added null check in the user loop with continue — skips failed users gracefully

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

Verification performed:

  • node --check scripts/sync-leaderboard.js — Syntax OK
  • npx prettier --check "frontend/**/*.{html,css,js}" "scripts/**/*.js" "server.js" — All files pass

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally using Prettier
  • 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

Screenshots / Screen Recording

N/A — Backend-only change with no UI impact.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

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.

A maintainer will review your submission shortly.

@jagdish-15 jagdish-15 added type:bug Something isn't working level:intermediate Indicates the difficulty gssoc:approved quality:clean labels Jun 8, 2026
@jagdish-15 jagdish-15 merged commit 0d601d5 into codepvg:main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved level:intermediate Indicates the difficulty quality:clean type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

process.exit(1) on Any Single User's API Failure Destroys Entire Sync Cycle

2 participants