Skip to main content

Retry, Timeout, and Backoff

Every client needs a deadline, a retry budget, and a rule for whether the operation is safe to retry. Without those constraints, outages become retry storms and transaction submits become duplicate-risk events.

OperationTimeoutRetry?Notes
Health checkShortYesRetry with small budget; use for routing only.
Read latest stateShort to mediumYesSafe if caller accepts changing latest state.
Read historical stateMediumYesFail over only to nodes with required retention.
Simulation/dry-runMediumYesInput must be identical; cache by request hash when useful.
Transaction submitMediumCarefullyRetry only with duplicate detection and chain-specific semantics.
Admin operationExplicit operator deadlineUsually noPrefer manual confirmation and audit trail.

Use exponential backoff with jitter. Stop when the caller's deadline expires, even if retry budget remains.

function nextDelayMs(attempt: number, baseMs = 250, capMs = 10_000): number {
const exponential = Math.min(capMs, baseMs * 2 ** attempt);
return Math.floor(exponential * (0.5 + Math.random()));
}

:::tip Idempotency first Decide idempotency before writing retry code. Retrying a read is usually safe; retrying a transaction submit may create duplicates, replace a nonce, or hide an already-accepted transaction. :::

Treat 429, 503, connection resets, and deadline exceeded as retryable only within policy. Treat validation errors, unauthorized responses, malformed requests, and method-not-found responses as non-retryable until the request changes.