Skip to content

feat(demo/stellar): Soroban RPC retry + exponential backoff (#59)#90

Merged
truthixify merged 1 commit into
wraith-protocol:developfrom
KaruG1999:feat/59-soroban-rpc-retry
Jun 26, 2026
Merged

feat(demo/stellar): Soroban RPC retry + exponential backoff (#59)#90
truthixify merged 1 commit into
wraith-protocol:developfrom
KaruG1999:feat/59-soroban-rpc-retry

Conversation

@KaruG1999

Copy link
Copy Markdown
Contributor

Description

This PR introduces a centralized resilience primitive (withRetry) to wrap network interactions with Horizon and Soroban RPC nodes, mitigating transient failures (408, 429, 502, 503, 504) and generic network drops (TypeError).

The core implementation leverages an exponential backoff algorithm coupled with a full random jitter formula to prevent stampeding or herd effects on infrastructure endpoints under load.

Technical Changes

Core Architecture (src/lib/stellar/retry.ts)

  • Implements withRetry<T>(fn, opts) using the exponential backoff calculation: $\min(\text{baseDelayMs} \times 2^{\text{attempt}-1} + \text{rand}(0, \text{baseDelayMs}), 30000)$.
  • Targets specific transient HTTP status codes via RETRYABLE_STATUS set and native TypeError boundaries. All other 4xx errors abort immediately.
  • Integrates native AbortSignal listeners to clear active timeouts and short-circuit thread execution instantly during component unmounts.

Component Integration & Idempotency Guardrails

  • Aisolation of Write Operations: Explicitly excludes all POST /transactions submission endpoints from the retry loop across StellarSend.tsx and StellarReceive.tsx to prevent non-idempotent submission hazards (double-spending/collisions).
  • Stealth Account Check Isolation: Enclosed the fetchWithRetry check inside an isolated try/catch/finally block in StellarSend.tsx. Persistent node degradation falls back to stealthExists = false instead of breaking the payment thread, preserving the original createAccount routing logic.
  • UI State Cleanup: Added a finally block to the best-effort Soroban propagation context to prevent the "Retrying (3/3)…" string from freezing on successful payment rendering screens.
  • Simulation Lifecycle: Wired AbortSignal directly into the debounce simulation effect within StellarSend.tsx to kill up to 6 orphan RPC queries on rapid input mutation.

Verification Results

Unit Testing (src/lib/stellar/retry.test.ts)

  • 22/22 passing specs verified using Vitest and MSW v2.
  • Verified execution paths for: early aborts, transient status code retries, validation failure rejections, and backoff boundary limits.

Compilation

  • Executed local TypeScript checks via tsc --noEmit. Zero errors introduced in modified file paths.

closes #59

Any feedback is welcome, thankss!!

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the truthixify's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

@truthixify

Copy link
Copy Markdown
Contributor

Clean merge. RPC retry + exponential backoff (retry.ts + 224-line tests + integration in StellarReceive/Send/Simulation) is solid. Vitest config + jitter handling all there. Thanks @KaruG1999.

@truthixify truthixify merged commit c9c04ca into wraith-protocol:develop Jun 26, 2026
0 of 2 checks 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.

Soroban RPC retry + exponential backoff

2 participants