Registry / testing / axios-retry

axios-retry

JSON →
library4.5.0jsnpmunverified

Intercepts failed axios requests and retries them automatically. Current version 4.5.0, actively maintained with releases on demand. Supports exponential backoff, custom retry conditions, and per-request config. Works with axios 0.x and 1.x. Ships TypeScript types. Differentiates from similar libraries (like axios-retry-plus) by being lightweight and focused on simple, flexible retry logic without external dependencies.

npm install axios-retry
INSTALL
IMPORT
SIG · AXIOS-RETRY
A
axios-retry
testingjavascriptv4.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (axiosRetry)
import axiosRetry from 'axios-retry'
import { axiosRetry } from 'axios-retry'
Default export only. Named export does not exist.
exponentialDelay
axiosRetry.exponentialDelay
import { exponentialDelay } from 'axios-retry'
Exported as property of default export, not named export.
linearDelay
axiosRetry.linearDelay()
axiosRetry.linearDelay
linearDelay is a factory function; must be called to get delay function.

Sets up axios-retry with exponential backoff on a custom axios instance, including per-request override and error handling.

import axios from 'axios'; import axiosRetry from 'axios-retry'; const client = axios.create({ baseURL: 'https://api.example.com' }); axiosRetry(client, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); async function fetchData() { try { const { data } = await client.get('/data', { 'axios-retry': { retries: 5 } // per-request override }); console.log(data); } catch (error) { console.error('Request failed after retries', error); } } fetchData();
Debug
Known issues
breakingIn v3, the default export changed from a function that returns a module to the function itself. Use import axiosRetry from 'axios-retry' instead of import * as axiosRetry from 'axios-retry'.
fix
Use default import.
affects: >=3.0.0
gotchaThe retryDelay option must be a function that returns milliseconds. Using a number will not work.
fix
Provide a function like (retryCount) => retryCount * 1000.
affects: >=0.1.0
gotchaThe axios timeout option is not reset between retries unless shouldResetTimeout is true. This can cause all retries to fail quickly.
fix
Set shouldResetTimeout: true in options.
affects: >=0.1.0
gotchaIn v4, the retryCondition default changed from isNetworkError to isNetworkOrIdempotentRequestError. GET/HEAD/PUT/DELETE/OPTIONS requests with 5xx errors will be retried by default now.
fix
To retry all 5xx errors, use a custom retryCondition that always returns true.
affects: >=4.0.0
gotchaCommonJS require() must use .default: const axiosRetry = require('axios-retry').default;
fix
Add .default or use import/import() syntax.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: axiosRetry is not a function
Using CommonJS require without .default
fix
const axiosRetry = require('axios-retry').default;
ERR_REQUIRE_ESM: require() of ES Module not supported
CommonJS require of an ESM-only module (axios-retry v3+ uses ESM by default)
fix
Use dynamic import: import('axios-retry') or enable ESM in your project.
Error: retryDelay is not a function
Passing a number to retryDelay instead of a function
fix
Use a function like (retryCount) => retryCount * 1000
AxiosError: timeout of 1000ms exceeded
Timeout not reset between retries (shouldResetTimeout defaults to false)
fix
Set shouldResetTimeout: true in axios-retry options
Upgrade
Version history
4.5.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency; required to intercept requests
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
axios-retry — npm install axios-retry · libregistry