Skip to content

perf(#281): add configurable retry with jitter to submitTransaction - #358

Merged
BigBen-7 merged 2 commits into
Lead-Studios:mainfrom
Userhorlie:feat/issue-281-retry-jitter
Jul 26, 2026
Merged

perf(#281): add configurable retry with jitter to submitTransaction#358
BigBen-7 merged 2 commits into
Lead-Studios:mainfrom
Userhorlie:feat/issue-281-retry-jitter

Conversation

@Userhorlie

@Userhorlie Userhorlie commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds configurable retry logic with ±20% random jitter to submitTransaction in src/utils/transaction.ts to reduce Horizon 429 collisions when multiple clients retry simultaneously.

Changes

  • Add SubmitTransactionOptions interface with maxRetries (default 3), retryDelayMs (default 1000), maxPollAttempts (default 20)
  • Retry submission on RATE_LIMIT_EXCEEDED errors, applying jitter: delay ± 20% of retryDelayMs
  • Backwards-compatible: bare number still accepted as maxPollAttempts
  • Export SubmitTransactionOptions from src/index.ts
  • Fix pre-existing bug in estimateFee (referenced tx/sourceAccount before declaration)
  • Fix pre-existing duplicate enum entries in VeriTixErrorCode

Tests

Added 6 new tests in tests/utils/transaction.test.ts:

  • Accepts maxRetries and retryDelayMs via options object
  • Retries on RATE_LIMIT_EXCEEDED up to maxRetries times
  • Throws after exhausting maxRetries on persistent rate limit
  • Jitter stays within ±20% bounds (statistical check over 200 samples)
  • Defaults maxRetries to 3 when no options supplied
  • Throws READ_ONLY_CLIENT when no keypair provided

Closes #281
Closes #282
Closes #283
Closes #285

…ransaction

- Add SubmitTransactionOptions interface with maxRetries (default 3),
  retryDelayMs (default 1000), and maxPollAttempts (default 20)
- Retry submission on RATE_LIMIT_EXCEEDED with ±20% random jitter to
  avoid thundering-herd collisions on concurrent submissions
- Maintain backwards-compat: bare number still accepted as maxPollAttempts
- Export SubmitTransactionOptions from src/index.ts
- Fix pre-existing estimateFee bug (used tx/sourceAccount before declaration)
- Fix pre-existing duplicate enum values in VeriTixErrorCode
- Add tests: retry with options, RATE_LIMIT retries, exhausted retries,
  jitter bounds, default options, READ_ONLY_CLIENT guard

Closes Lead-Studios#281
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Userhorlie 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

@BigBen-7

Copy link
Copy Markdown
Collaborator

This PR currently has merge conflicts with main and was skipped during the batch merge pass. Please rebase/resolve conflicts and it can be merged.

@BigBen-7
BigBen-7 merged commit a4ffd25 into Lead-Studios:main Jul 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment