Skip to content

feat: add retry-with-backoff for failed trade fetches - #577

Merged
dark-sarge merged 1 commit into
arflexx:mainfrom
Scepter00:issue460-retry-with-backoff
Oct 22, 2026
Merged

dark-sarge merged 1 commit into
arflexx:mainfrom
Scepter00:issue460-retry-with-backoff

Conversation

@Scepter00

Copy link
Copy Markdown
Contributor

Summary
Implements an exponential backoff retry mechanism for transient network failures when fetching trades, significantly improving the reliability of the trades page.

Changes
frontend/hooks/: Created a reusable fetch hook supporting configurable max attempts, jittered exponential backoff, transient error filtering (5xx, timeouts, network errors), attempt tracking, and abort/cancel capabilities.

frontend/app/trades/: Integrated the new retry hook into the trades fetching logic to display persistent progress/loading states during retry attempts and handle exhausted retries gracefully.

Acceptance Criteria Checklist
[x] Reusable fetch hook with configurable max attempts and exponential backoff

[x] Retries restricted to transient failures (network, timeout, 5xx) while skipping 4xx client errors

[x] Trades page displays a loading/progress state during retries and surfaces a clear error only after all attempts are exhausted

[x] Jittered backoff timing to prevent thundering-herd issues

[x] Hook exposes the current attempt count and an abort/cancel capability

Testing & Verification
Simulated intermittent network drops and confirmed requests automatically retry with appropriate backoff delays.

Verified that 4xx errors (e.g., 400 Bad Request, 404 Not Found) fail immediately without triggering retries.

Tested manual abort/cancellation to ensure pending retries and network requests are successfully cleaned up.

Closes #460

- Add reusable retry-with-backoff logic for API fetches in trade hooks
- Retries only for transient failures (5xx server errors, network/timeouts), not 4xx client errors
- Jittered exponential backoff between retry attempts to avoid thundering-herd
- Hooks expose attempt count and abort/cancel capability
- Trades page shows loading/progress state during retries, clear error only after all attempts exhausted

Files modified:
- hooks/useTrade.ts: Added retry logic with 3 max attempts, backoff, and transient error filtering
- hooks/useTradeList.ts: Added retry logic with 3 max attempts, backoff, and transient error filtering
- hooks/__tests__/useTradeList.test.ts: Updated tests to match new retry behavior
- hooks/useFetchWithRetry.ts: New reusable hook with configurable max attempts, initial delay, max delay, jitter, and onRetry callback

Co-authored-by: Codebuff <noreply@codebuff.com>
@Scepter00
Scepter00 requested a review from dark-sarge as a code owner October 22, 2026 06:33
@drips-wave

drips-wave Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Scepter00 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dark-sarge
dark-sarge merged commit 66e8d5b into arflexx:main Oct 22, 2026
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.

[Frontend] - Add Retry With Backoff for Failed Trade Fetches

2 participants