Skip to content

Implement retry logic with exponential backoff and circuit breaker for all RPC calls #419

Description

@Kingsman-99

Overview

Soroban RPC calls can fail transiently. Add a resilience layer to StellarSplitClient with configurable retry logic (exponential backoff with jitter) and a circuit breaker that opens after N consecutive failures and auto-resets after a cooldown period.

Requirements

  • All RPC calls in StellarSplitClient wrapped with retry logic
  • RetryConfig { maxRetries: number, baseDelayMs: number, maxDelayMs: number, jitter: boolean }
  • CircuitBreakerConfig { failureThreshold: number, resetTimeoutMs: number }
  • Circuit breaker states: CLOSED (normal) → OPEN (failing fast) → HALF-OPEN (testing recovery)
  • Emit circuit state change events via client.on('circuit:open' | 'circuit:close' | 'circuit:half-open', cb)
  • Non-retryable errors (e.g. InvalidInput, Unauthorized) must bypass retry immediately
  • Write tests: retry exhaustion, circuit opens after threshold, circuit resets after timeout, non-retryable errors skip retry

Acceptance Criteria

  • Retry with exponential backoff + jitter on all RPC calls
  • Circuit breaker with all 3 states implemented
  • Non-retryable errors bypass retry
  • Circuit state change events emitted
  • All existing tests pass
  • npm test passes with zero failures
  • TypeScript compiles with zero errors
  • ESLint passes with zero errors

Definition of Done

All CI checks must pass before the PR is reviewed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions