feat: handle Horizon 429 rate limiting with backoff - #272
Merged
RaceeyXo merged 1 commit intoSep 1, 2026
Merged
Conversation
- Add retryWithBackoff utility that reads Retry-After header on 429 responses and waits the exact number of seconds Horizon asks before retrying. Other retriable errors (5xx, network) use full-jitter exponential back-off (base 500ms, cap 30s, up to maxRetries times). - Integrate retryWithBackoff into useQuery so all read hooks benefit automatically. Default: up to 3 retries on 429 only (retryOn5xx is opt-in to avoid breaking existing error-handling behaviour). - Expose rateLimitedUntilRef from useQuery so useBalance can inspect it. - Update useBalance polling to skip interval ticks while a 429 rate-limit window is still active, preventing the fixed-interval hammer that worsens the rate-limit situation. - Add maxRetries option to useAccount, useAsset, useBalance, useClaimableBalance, usePayments, and useTransaction so consumers can tune retry behaviour per hook. - Add 32 unit tests covering isRetriable, getRetryAfterMs, computeBackoffDelay, and retryWithBackoff (including abort-signal cancellation and the retryOn5xx flag). Closes: Horizon 429 rate-limiting issue (medium complexity)
|
@joshuaodoh122-hub 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.
Closes #193