Skip to content

fix: Add retry policy presets (aggressive/conservative)#714

Merged
wheval merged 2 commits into
ancore-org:mainfrom
10xwhoman:fix/issues-601
May 30, 2026
Merged

fix: Add retry policy presets (aggressive/conservative)#714
wheval merged 2 commits into
ancore-org:mainfrom
10xwhoman:fix/issues-601

Conversation

@10xwhoman
Copy link
Copy Markdown
Contributor

Summary

Add retry policy presets for wallet and indexer call sites, wire StellarClient to the conservative wallet preset by default, and document how apps override retry behavior under rate limits.

Purpose / Motivation

Stellar Horizon and RPC endpoints can return HTTP 429 under load. Wallet flows and background indexers have different latency and resilience needs. Centralized presets make the right defaults easy to adopt while still allowing per-app overrides.

Changes Made

  • Export RETRY_PRESETS (wallet: 3 attempts / 200 ms, indexer: 5 attempts / 500 ms) from packages/stellar/src/retry.ts
  • Add retryOptionsFromPreset and resolveRetryOptions helpers to convert presets into RetryOptions
  • Update StellarClient to accept retryPreset and default to wallet, with retryOptions merged on top
  • Add tests that simulate HTTP 429 with mocked fetch, including success after retry and RetryExhaustedError on exhaustion
  • Add packages/stellar/README.md documenting preset selection and override behavior

How to Test

  1. Run package tests:

    cd packages/stellar
    npm test

    Expected: all tests pass, including new RETRY_PRESETS and client preset coverage.

  2. Verify default client preset:

    import { StellarClient } from '@ancore/stellar';
    
    const client = new StellarClient({ network: 'testnet' });

    Expected: client uses wallet preset (maxRetries: 2, baseDelayMs: 200).

  3. Verify indexer override:

    const indexer = new StellarClient({ network: 'testnet', retryPreset: 'indexer' });

    Expected: client uses indexer preset (maxRetries: 4, baseDelayMs: 500).

  4. Verify custom override:

    const client = new StellarClient({
      network: 'testnet',
      retryPreset: 'wallet',
      retryOptions: { maxRetries: 1 },
    });

    Expected: maxRetries is overridden while other wallet preset values remain.

Breaking Changes

  • StellarClient default retry behavior changes from { maxRetries: 3, baseDelayMs: 1000 } to the wallet preset { maxRetries: 2, baseDelayMs: 200 }. Apps relying on the old implicit default can pass explicit retryOptions to preserve prior behavior.

Related Issues

Closes #601

Checklist

  • Code builds successfully
  • Tests added/updated
  • No console errors
  • Documentation updated (if needed)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@10xwhoman, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 21 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb953a45-a37c-4470-92a3-6abec48bc18c

📥 Commits

Reviewing files that changed from the base of the PR and between c275eac and 0be9b2e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/stellar/README.md
  • packages/stellar/src/__tests__/client.test.ts
  • packages/stellar/src/__tests__/retry.test.ts
  • packages/stellar/src/client.ts
  • packages/stellar/src/index.ts
  • packages/stellar/src/retry.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@10xwhoman 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

Copy link
Copy Markdown
Contributor

@wheval wheval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@wheval wheval merged commit 65ff459 into ancore-org:main May 30, 2026
1 check 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.

[STELLAR] Add retry policy presets (aggressive/conservative)

2 participants