Skip to content

Feat: Implement Missing request timeout handling in frontend API calls#193

Open
Lansa-18 wants to merge 1 commit into
ChainForgee:mainfrom
Lansa-18:feat/issue-122-frontend-request-timeout
Open

Feat: Implement Missing request timeout handling in frontend API calls#193
Lansa-18 wants to merge 1 commit into
ChainForgee:mainfrom
Lansa-18:feat/issue-122-frontend-request-timeout

Conversation

@Lansa-18

Copy link
Copy Markdown
Contributor

Closes #122

Feat: Request Timeout Handling for Frontend API Calls (#122)

Summary

Adds request timeout handling to all frontend API calls. Previously, apiClient (openapi-fetch) delegated to native fetch with no timeout, meaning any network request would hang indefinitely if the backend was unresponsive — degrading UX especially in poor connectivity environments.

The fix wraps fetchClient with an AbortController-based timeout at the api-client.ts level, so every existing and future API call inherits the 30s default automatically with no per-call changes needed. withRetry is also patched to not retry timed-out requests (which would have silently extended the hang by ~7s). Timeout errors surface a user-readable message instead of a silent hang.


Testing

Unit Tests — New Utility

cd app/frontend
pnpm test -- --testPathPatterns=fetch-timeout --no-coverage
# Tests: 12 passed, 12 total

Covers:

  • Request resolves normally before timeout
  • Timeout fires and aborts the request
  • Timer is cleared on successful response (no dangling timers)
  • Pre-aborted caller signal causes immediate abort
  • Caller signal fires independently before timeout
  • Default DEFAULT_TIMEOUT_MS (30s) is used when no value is specified
  • isTimeoutError correctly identifies AbortError and TimeoutError, rejects plain errors

Full Test Suite — Regression Check

pnpm test -- --no-coverage
# Test Suites: 10 passed, 10 total
# Tests:       94 passed, 94 total

Type Check

pnpm type-check
# clean, no output

Build

pnpm build
# ✓ Compiled successfully in 700ms

Lint

pnpm lint
# 14 pre-existing errors, none in files touched by this PR
# All errors are in unrelated components (campaigns/page.tsx, DashboardContent.tsx, useActivity.ts, etc.)

Notes

No UI changes. Timeout errors surface through existing error states in TanStack Query consumers.


Checklist

  • Tests added or updated for new/changed behavior
  • Existing tests pass
  • No secrets, keys, or seed phrases committed
  • Follows the coding conventions in the relevant service README
  • PR is focused on a single concern

@Lansa-18

Copy link
Copy Markdown
Contributor Author

@kilodesodiq-arch Kindly review the PR. Thank you.

@kilodesodiq-arch

Copy link
Copy Markdown
Contributor

@Lansa-18 please check, the CI didnt run.

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.

[MEDIUM] Missing request timeout handling in frontend API calls

2 participants