Skip to main content

@std/async@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Classes

c
RetryError(
cause: unknown,
attempts: number
)

Error thrown in retry once the maximum number of failed attempts has been reached.

Functions

f
retry<T>(
fn: (() => Promise<T>) | (() => T),
opts?: RetryOptions
): Promise<T>

Calls the given (possibly asynchronous) function up to maxAttempts times. Retries as long as the given function throws. If the attempts are exhausted, throws a RetryError with cause set to the inner exception.

Interfaces

I

Options for retry.

  • jitter: number

    Amount of jitter to introduce to the time between attempts. This is 1 for full jitter by default.

  • maxAttempts: number

    The maximum amount of attempts until failure.

  • maxTimeout: number

    The maximum milliseconds between attempts.

  • minTimeout: number

    The initial and minimum amount of milliseconds between attempts.

  • multiplier: number

    How much to backoff after each retry.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/async

Import symbol

import * as mod from "@std/async/retry";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/async/retry";