Skip to content

Retry + exponential backoff for Soroban RPC #2

@truthixify

Description

@truthixify

Labels: Stellar Wave, stellar, resilience, drips, help-wanted
Tier: M (2–4 days)
Type: resilience

Context

The Stellar Receive page calls Soroban RPC for getEvents, Horizon for balance lookups, and the announcer contract for occasional reads. Today every call is single-attempt — a single 429 or transient 502 surfaces directly to the user as "scan failed". This is unacceptably brittle.

We need a small retry primitive shared across all Stellar HTTP calls.

Scope

Add src/lib/stellar/retry.ts with a withRetry(fn, opts) helper that:

  1. Attempts up to N times (default 4).
  2. Backs off exponentially with jitter: 200ms, 400ms, 800ms, 1600ms, each ±25%.
  3. Retries only on specific failure classes:
    • HTTP 408, 429, 502, 503, 504
    • Network errors / aborted fetches
    • JSON parse errors (sometimes RPC returns HTML on overload)
  4. Does NOT retry on:
    • HTTP 4xx other than 408/429
    • Bad request / invalid input
    • Auth failures
  5. Throws a typed StellarRetryExhaustedError after final attempt, carrying the last error.
  6. Respects an AbortSignal from the caller (e.g., user navigated away).

Wire it into:

  • src/components/StellarSend.tsx Soroban announcer write
  • src/components/StellarReceive.tsx scan loop and balance fetch
  • Any other Stellar fetch helpers

Acceptance criteria

  • retry.ts implementation with unit tests using mocked fetch.
  • All Stellar fetches wrapped.
  • User-facing error UI on StellarRetryExhaustedError shows: "Network unstable — try again." with a retry button (not a generic stack trace).
  • Telemetry hook: emit an event when a retry happens (we can wire this to PostHog later).

Why this matters

Soroban RPC rate limits on public endpoints are tight. Spectre's polling already pressures the same endpoints. Any user-perceived demo flakiness undercuts our entire credibility on Stellar.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programdripsFunded via Drips Networkhelp wantedExtra attention is neededresilienceError handling / retriesstellarTouches Stellar / Soroban code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions