Skip to content

fix: add 8s fetch timeouts to CodeChef, Codeforces, GitHub REST, and GitHub GraphQL services#104

Merged
SamXop123 merged 3 commits into
SamXop123:mainfrom
rishab11250:fix/fetch-timeouts-services
May 29, 2026
Merged

fix: add 8s fetch timeouts to CodeChef, Codeforces, GitHub REST, and GitHub GraphQL services#104
SamXop123 merged 3 commits into
SamXop123:mainfrom
rishab11250:fix/fetch-timeouts-services

Conversation

@rishab11250
Copy link
Copy Markdown
Contributor

Description

Added AbortController-based 8-second fetch timeouts to all external API services that were missing them. LeetCode service already had this pattern (8s timeout) — this PR applies the same pattern to the remaining services.

Changes

  • src/services/codechef.service.js — Added 8s AbortController timeout to getCodeChefData()
  • src/services/codeforces.service.js — Added shared 8s AbortController timeout to both parallel fetches in getCodeforcesData()
  • src/services/github.service.js — Added 8s timeouts to fetchUserProfile(), fetchUserRepos() (per pagination page), and updated fetchAvatarDataUri() timeout from 4s → 8s
  • src/services/github-graphql.service.js — Added 8s AbortController timeout with try/catch to fetchContributionData()

Pattern used (consistent across all services)

  • AbortController + setTimeout(() => controller.abort(), 8000)
  • signal: controller.signal in fetch options
  • clearTimeout(timeout) after successful response
  • Catch block translates AbortError → user-friendly timeout message (e.g. "CodeChef API timeout")

Testing

  • All 12 existing unit tests pass (npm run test:unit)

Closes #100

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@rishab11250 is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Owner

@SamXop123 SamXop123 left a comment

Choose a reason for hiding this comment

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

✅✅

@SamXop123 SamXop123 merged commit c9535eb into SamXop123:main May 29, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: add fetch timeouts to CodeChef, Codeforces, and GitHub services to prevent stalled requests

2 participants