Skip to content

fix(client): add exponential backoff retry and Horizon error decoder (closes #974) - #980

Open
area523ufo wants to merge 1 commit into
Sorokit:mainfrom
area523ufo:fix/client-retry-backoff-horizon-decoder-974
Open

area523ufo wants to merge 1 commit into
Sorokit:mainfrom
area523ufo:fix/client-retry-backoff-horizon-decoder-974

Conversation

@area523ufo

Copy link
Copy Markdown

Closes #974

Summary

Enhances StellarClient in src/lib/client.ts:

  1. Exponential backoff retry for transient failures: Added withRetry() with configurable maxRetries and retryBaseDelayMs (baseDelay * 2^attempt) that automatically retries transient network / HTTP 429 / 5xx / tx_too_late errors while immediately surfacing non-retryable errors.
  2. Horizon error code decoder: Added decodeHorizonError() and HORIZON_ERROR_MESSAGES mapping standard Stellar Horizon transaction & operation result codes (tx_failed, tx_bad_seq, tx_insufficient_balance, tx_insufficient_fee, op_underfunded, op_no_trust, op_line_full, etc.) to human-readable descriptions.
  3. Request timeout handling: Added configurable requestTimeoutMs enforced on RPC calls.

Verification

  • Expanded src/lib/__tests__/mock-client.test.ts with tests for retry backoff on transient failures, non-retryable error fast failure, timeout handling, and Horizon error code decoding.
  • All unit tests pass via npx vitest run.

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 exponential backoff retry and Horizon error decoder in client.ts

1 participant