Repository navigation
feat: add retry-with-backoff for failed trade fetches - #577
Merged
Merged
Conversation
- 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 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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