Skip to content

retry

retry<E>(options): <A>(data) => TaskResult<E, A>

Defined in: Core/TaskResult.ts:130

Re-runs a TaskResult on Err with configurable attempts, backoff, and retry condition.

E

number

Total number of attempts (1 = no retry, 3 = up to 3 tries)

number | (attempt) => number

Fixed delay in ms, or a function (attempt) => ms for computed delay

(error) => boolean

Only retry when this returns true; defaults to always retry on Err

<A>(data): TaskResult<E, A>

A

TaskResult<E, A>

TaskResult<E, A>

// Retry up to 3 times with exponential backoff
pipe(
  fetchUser,
  TaskResult.retry({ attempts: 3, backoff: n => n * 1000 })
);

// Only retry on network errors, not auth errors
pipe(
  fetchUser,
  TaskResult.retry({ attempts: 3, when: e => e instanceof NetworkError })
);