Skip to content

feat(retry): rewrite withRetry helper for public export and configurability - #658

Merged
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
ZacLou:feat/rewrite-with-retry-648
Sep 3, 2026
Merged

feat(retry): rewrite withRetry helper for public export and configurability#658
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
ZacLou:feat/rewrite-with-retry-648

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Rewrites the withRetry helper introduced in #648 so it is actually exported from the public API and is configurable enough for reuse beyond the internal RPC proxy.

What changed

  • Public export: withRetry, WithRetryOptions, and the new isTransientRpcError predicate are now exported from src/index.ts.
  • Configurability: added maxDelayMs, jitter (
    one / ull / �qual), a custom shouldRetry predicate, AbortSignal cancellation, and an onRetry hook.
  • Backward-compatible defaults: by default the helper still retries only RateLimitError, honours Retry-After, and falls back to exponential backoff.
  • Error classification: raw RPC-shaped errors are classified with RateLimitError.fromRpcError inside the helper so callers and predicates receive typed errors.
  • Tests: added dedicated unit tests in src/tests/with-retry.test.ts covering success, Retry-After, exponential backoff, max delay cap, jitter, custom predicates, onRetry, and abort.

Verification

px tsc --noEmit passes.

px eslint src --ext .ts passes.

px vitest run src/tests/with-retry.test.ts src/tests/soroban-retry-after.test.ts src/tests/soroban-rate-limit.test.ts passes (20/20).

References

…bility

Rewrites the withRetry helper introduced in conduit-protocol#648 so it is actually
exported from the public API and is configurable enough for reuse
beyond the RPC proxy:

- Exports withRetry, WithRetryOptions, and isTransientRpcError from
  src/index.ts (the previous PR claimed this but omitted the change).
- Adds maxDelayMs cap, full/equal jitter strategies, AbortSignal
  cancellation, a custom shouldRetry predicate, and an onRetry hook.
- Preserves default behaviour: retry only RateLimitError, honour
  Retry-After, and fall back to exponential backoff.
- Classifies raw RPC errors with RateLimitError.fromRpcError inside
  the helper so callers and predicates receive typed errors.
- Adds dedicated unit tests in src/tests/with-retry.test.ts.

Refs conduit-protocol#648, conduit-protocol#620.
@Jaydbrown
Jaydbrown merged commit 4dc046d into conduit-protocol:main Sep 3, 2026
3 of 5 checks passed
Jaydbrown added a commit that referenced this pull request Sep 3, 2026
The squash-merge of #658 regressed package-lock.json to a stale state that
dropped the standalone node_modules/@emnapi/core and @emnapi/runtime nodes,
breaking `npm ci` on CI (npm 10):
  Missing: @emnapi/core@2.0.0-alpha.3 from lock file

Restore the lockfile to its pre-#658 state, which is in sync with the
current package.json (that PR did not change package.json).
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.

3 participants