Skip to content

feat: handle Horizon 429 rate limiting with backoff - #272

Merged
RaceeyXo merged 1 commit into
RaceeyXo:devfrom
joshuaodoh122-hub:feat/horizon-429-rate-limit-backoff
Sep 1, 2026
Merged

feat: handle Horizon 429 rate limiting with backoff#272
RaceeyXo merged 1 commit into
RaceeyXo:devfrom
joshuaodoh122-hub:feat/horizon-429-rate-limit-backoff

Conversation

@joshuaodoh122-hub

Copy link
Copy Markdown
  • 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 #193

- 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)
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@RaceeyXo
RaceeyXo merged commit 71675f2 into RaceeyXo:dev Sep 1, 2026
2 of 3 checks passed
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.

feat(core): handle Horizon 429 rate limiting with backoff

2 participants