📄 tanstack/pacer/latest/docs/reference/functions/asyncRetry

File: asyncRetry.md | Updated: 11/15/2025

Source: https://tanstack.com/pacer/latest/docs/reference/functions/asyncRetry



TanStack

Pacer v0v0

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

Latest

Search...

+ K

Menu

Getting Started

Guides

API Reference

Debouncer API Reference

Throttler API Reference

Rate Limiter API Reference

Queue API Reference

Batcher API Reference

Debouncer Examples

Throttler Examples

Rate Limiter Examples

Queue Examples

Batcher Examples

TanStack Query Examples

Framework

React logo

React

Version

Latest

Menu

Getting Started

Guides

API Reference

Debouncer API Reference

Throttler API Reference

Rate Limiter API Reference

Queue API Reference

Batcher API Reference

Debouncer Examples

Throttler Examples

Rate Limiter Examples

Queue Examples

Batcher Examples

TanStack Query Examples

On this page

asyncRetry

Copy Markdown

Function: asyncRetry()
======================

ts

function asyncRetry<TFn>(fn, initialOptions): (...args) => Promise<Awaited<ReturnType<TFn>> | undefined>;


function asyncRetry<TFn>(fn, initialOptions): (...args) => Promise<Awaited<ReturnType<TFn>> | undefined>;

Defined in: async-retryer.ts:658

Creates a retry-enabled version of an async function. This is a convenience wrapper around the AsyncRetryer class that returns the execute method.

Type Parameters
---------------
### TFn

TFn extends AnyAsyncFunction

Parameters
----------
### fn

TFn

The async function to add retry functionality to

### initialOptions

AsyncRetryerOptions <TFn> = {}

Configuration options for the retry behavior

Returns
-------

A new function that executes the original with retry logic

ts

(...args): Promise<Awaited<ReturnType<TFn>> | undefined>;


(...args): Promise<Awaited<ReturnType<TFn>> | undefined>;

### Parameters #### args

...Parameters<TFn>

### Returns

Promise<Awaited<ReturnType<TFn>> | undefined>

Example
-------

typescript

// Define your async function normally
async function fetchData(url: string) {
  const response = await fetch(url)
  if (!response.ok) throw new Error('Request failed')
  return response.json()
}

// Create retry-enabled function
const fetchWithRetry = asyncRetry(fetchData, {
  maxAttempts: 3,
  backoff: 'exponential',
  baseWait: 1000,
  jitter: 0.1
})

// Call it multiple times
const data1 = await fetchWithRetry('/api/data1')
const data2 = await fetchWithRetry('/api/data2')


// Define your async function normally
async function fetchData(url: string) {
  const response = await fetch(url)
  if (!response.ok) throw new Error('Request failed')
  return response.json()
}

// Create retry-enabled function
const fetchWithRetry = asyncRetry(fetchData, {
  maxAttempts: 3,
  backoff: 'exponential',
  baseWait: 1000,
  jitter: 0.1
})

// Call it multiple times
const data1 = await fetchWithRetry('/api/data1')
const data2 = await fetchWithRetry('/api/data2')

Edit on GitHub

Home

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics