Polkadot Apps
    Preparing search index...

    Function withRetry

    • Wrap an async function with retry logic and exponential backoff.

      Only retries transient errors (network disconnects, temporary RPC failures). Deterministic errors (TxDispatchError, TxBatchError), user rejections (TxSigningRejectedError), and timeouts (TxTimeoutError) are rethrown immediately without retry.

      Type Parameters

      • T

      Parameters

      • fn: () => Promise<T>

        The async function to retry.

      • Optionaloptions: RetryOptions

        Retry configuration.

      Returns Promise<T>

      The result of the first successful call.

      const result = await withRetry(
      () => submitAndWatch(tx, signer),
      { maxAttempts: 3, baseDelayMs: 1_000 },
      );