Skip to content

feat: retry/backoff for transient Stellar RPC errors#2

Open
jaydenkalu wants to merge 1 commit into
mainfrom
issues/496-stellar-retry-backoff
Open

feat: retry/backoff for transient Stellar RPC errors#2
jaydenkalu wants to merge 1 commit into
mainfrom
issues/496-stellar-retry-backoff

Conversation

@jaydenkalu

Copy link
Copy Markdown
Owner

Closes AnnabelJoe#496

Summary

Adds configurable exponential backoff retry logic to rpcCall() in stellar.ts so transient network/RPC errors are automatically retried without human intervention.

Changes — src/lib/stellar.ts

  • isTransient(err): identifies retryable errors — StellarTimeoutError, plus network errors matching ECONNRESET, ENOTFOUND, HTTP 503/429
  • rpcCall(): retry loop with exponential backoff:
    • attempt 0 → BASE_MS, attempt 1 → 2×BASE_MS, … capped at MAX_MS
    • Non-transient errors (e.g. contract errors) propagate immediately
    • Circuit breaker still opens after 5 consecutive timeouts
  • Env-configurable (all have safe defaults):
Variable Default Purpose
STELLAR_RETRY_MAX 3 Max retry attempts
STELLAR_RETRY_BASE_MS 500 Base delay
STELLAR_RETRY_MAX_MS 8000 Max delay cap
STELLAR_RPC_TIMEOUT_MS 10000 Per-call timeout

Testing

  • TypeScript type-check passes
  • No regressions in existing test suite

)

- Configurable exponential backoff via env vars:
    STELLAR_RETRY_MAX (default: 3)
    STELLAR_RETRY_BASE_MS (default: 500ms)
    STELLAR_RETRY_MAX_MS (default: 8000ms)
    STELLAR_RPC_TIMEOUT_MS (default: 10000ms)
- isTransient() identifies retryable errors (timeout, ECONNRESET, 503/429)
- rpcCall() retries up to RETRY_MAX times with exponential delay
- Permanent failures (non-transient) surfaced immediately without retrying
- Circuit breaker unchanged: opens after 5 consecutive timeouts
- Structured logging via logger.warn on retries and circuit events

Closes AnnabelJoe#496
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.

Add retry/backoff for transient Stellar RPC errors

1 participant