These libraries enhance HTTP request capabilities in Node.js and browser environments by providing built-in retry mechanisms. They are designed to handle transient errors, ensuring that requests are retried automatically without requiring additional logic from the developer. This is particularly useful in scenarios where network reliability is a concern, as it improves the robustness of applications by minimizing the impact of temporary failures.
Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
Package
Downloads
Stars
Size
Issues
Publish
License
axios-retry
0
2,012
33.6 kB
58
2 years ago
Apache-2.0
fetch-retry
0
317
55.2 kB
6
2 years ago
MIT
got
0
14,876
304 kB
1
3 months ago
MIT
node-fetch-retry
0
9
7.94 kB
3
-
MIT
superagent-retry
0
85
-
10
10 years ago
-
Feature Comparison: axios-retry vs fetch-retry vs got vs node-fetch-retry vs superagent-retry
Integration
axios-retry:
Integrates directly with Axios, allowing you to leverage existing Axios configurations and interceptors while adding retry logic seamlessly.
fetch-retry:
Works as a wrapper around the Fetch API, enabling retry functionality without altering the core fetch implementation, making it easy to adopt in existing codebases.
got:
Built into the Got library, providing a comprehensive solution for HTTP requests with retry capabilities, making it a one-stop solution for developers.
node-fetch-retry:
Enhances node-fetch by adding retry logic, maintaining a familiar API for those used to the Fetch API in a Node.js context.
superagent-retry:
Extends Superagent's functionality, allowing users to maintain their existing Superagent codebase while adding retry capabilities effortlessly.
Customization
axios-retry:
Offers extensive customization options for retry strategies, including the ability to specify which status codes should trigger a retry and the delay between retries.
fetch-retry:
Allows customization of retry attempts and delay intervals, giving developers control over how retries are handled based on their application's needs.
got:
Provides advanced customization options, including retry on specific status codes, custom error handling, and configurable retry delays, making it highly flexible for various use cases.
node-fetch-retry:
Supports customizable retry options, allowing developers to specify the number of retries and delay between attempts, ensuring it fits specific application requirements.
superagent-retry:
Allows for configuration of retry attempts and delay, enabling developers to tailor the retry behavior to suit their application's needs.
Error Handling
axios-retry:
Handles errors gracefully by allowing retries on specific HTTP status codes, which can be configured, thus improving user experience during transient failures.
fetch-retry:
Provides a simple way to manage errors by retrying failed requests, which is particularly useful for handling network issues in client-side applications.
got:
Includes robust error handling capabilities, allowing retries based on response status and providing detailed error messages to aid in debugging.
node-fetch-retry:
Facilitates error handling by automatically retrying failed requests, which helps maintain application stability during network fluctuations.
superagent-retry:
Enhances Superagent's error handling by adding retry logic, allowing for improved resilience against temporary network issues.
Performance
axios-retry:
Minimal performance overhead due to its integration with Axios, ensuring that retry logic does not significantly impact the overall request performance.
fetch-retry:
Lightweight and efficient, it adds minimal overhead to fetch requests, making it suitable for performance-sensitive applications.
got:
Optimized for performance with built-in retry logic, ensuring that retries are handled efficiently without unnecessary delays.
node-fetch-retry:
Maintains the performance characteristics of node-fetch while adding retry capabilities, ensuring that applications remain responsive.
superagent-retry:
Offers good performance with minimal impact on request speed, allowing for efficient handling of retries without sacrificing responsiveness.
Community Support
axios-retry:
Backed by a large community due to its association with Axios, ensuring ample resources and support are available for developers.
fetch-retry:
While not as widely used as Axios, it benefits from the popularity of the Fetch API, with a growing community and support resources.
got:
Has a strong community and extensive documentation, making it easy for developers to find help and examples for implementing retries effectively.
node-fetch-retry:
Supported by the node-fetch community, providing access to resources and discussions related to its use and best practices.
superagent-retry:
Part of the Superagent ecosystem, it enjoys community support and resources, making it easier for developers to implement and troubleshoot.
How to Choose: axios-retry vs fetch-retry vs got vs node-fetch-retry vs superagent-retry
axios-retry:
Choose axios-retry if you are already using Axios for your HTTP requests and need a straightforward way to add retry functionality. It integrates seamlessly with Axios and allows for customizable retry strategies based on response status codes or errors.
fetch-retry:
Select fetch-retry if you are using the Fetch API and want to add retry capabilities without changing your existing fetch calls. It is lightweight and works well in browser environments, making it ideal for client-side applications.
got:
Opt for got if you need a powerful HTTP request library with built-in retry support and advanced features like streams and cancellation. Got is well-suited for server-side applications and offers a rich set of options for handling requests and responses.
node-fetch-retry:
Use node-fetch-retry if you prefer a lightweight implementation of the Fetch API for Node.js with retry capabilities. It is a good choice for projects that require a familiar fetch interface in a Node.js environment without additional overhead.
superagent-retry:
Choose superagent-retry if you are using Superagent and want to enhance its capabilities with retry functionality. It is particularly useful for projects that already utilize Superagent for making HTTP requests and need a simple way to handle retries.
Popular Comparisons
Similar Npm Packages to axios-retry
axios-retry is a popular library that enhances the functionality of Axios, a widely-used HTTP client for JavaScript. This package allows developers to automatically retry failed HTTP requests, which can be particularly useful in scenarios where network issues or server errors might temporarily prevent a request from succeeding. With configurable options for the number of retries, delay between attempts, and conditions under which to retry, axios-retry provides a robust solution for improving the reliability of API interactions in applications.
While axios-retry is a great option for adding retry functionality to Axios requests, there are alternatives available that serve similar purposes. One notable alternative is:
retry-axios. This library is built specifically for retrying Axios requests and offers a similar feature set to axios-retry. It provides automatic retries for failed requests, allowing developers to specify the number of retry attempts and the conditions under which retries should occur. retry-axios is designed to be simple to use and integrates seamlessly with Axios, making it an excellent choice for developers looking for an alternative to axios-retry.
fetch-retry is a JavaScript library that enhances the native Fetch API by adding retry functionality for failed requests. This is particularly useful when dealing with unreliable networks or APIs that may occasionally fail. With fetch-retry, developers can specify the number of retry attempts, delay between retries, and other options to ensure that their applications can gracefully handle transient errors. This library is a great choice for projects that rely heavily on the Fetch API and need robust error handling for network requests.
There are several alternatives to fetch-retry that also provide retry capabilities for HTTP requests:
axios-retry is a library designed to work with Axios, a popular promise-based HTTP client. It allows developers to automatically retry failed requests with configurable options, such as the number of retries and the delay between attempts. If you're already using Axios in your project, axios-retry is a natural choice to enhance your HTTP request handling with retry logic. It integrates seamlessly with Axios and provides a straightforward API for configuring retries.
node-fetch-retry is a retry wrapper for the node-fetch library, which is a lightweight module that brings window.fetch to Node.js. Similar to fetch-retry, node-fetch-retry allows developers to specify retry logic for failed requests made with node-fetch. This library is particularly useful for server-side applications built with Node.js that need to make HTTP requests and require robust error handling.
got is a popular HTTP request library for Node.js, designed to simplify the process of making HTTP requests while providing a rich set of features. It supports promises and async/await syntax, making it easy to work with asynchronous code. got is known for its performance, ease of use, and built-in support for advanced features like retries, timeouts, and streaming. It is an excellent choice for developers looking to make HTTP requests in a Node.js environment.
While got is a powerful option, there are several alternatives available that also provide robust HTTP request capabilities. Here are a few notable ones:
axios is a widely-used promise-based HTTP client for both the browser and Node.js. It offers a simple API and supports features such as interceptors, request cancellation, and automatic JSON data transformation. axios is particularly popular for frontend applications but can also be used effectively in server-side code. If you need a versatile HTTP client that works seamlessly in both environments, axios is a great choice.
node-fetch is a lightweight module that brings the fetch API to Node.js. It is designed to be a minimalistic and straightforward implementation of the fetch API, making it easy for developers familiar with the browser's fetch to make HTTP requests in a Node.js environment. If you prefer a simple and native-like API for making requests, node-fetch is an excellent alternative.
request was once a popular HTTP request library for Node.js, known for its simplicity and ease of use. However, it has been deprecated in favor of more modern alternatives like got and axios. While it is still available, it is recommended to use more actively maintained libraries for new projects.
node-fetch-retry is a package that enhances the popular node-fetch library by adding retry functionality for failed HTTP requests. This is particularly useful when dealing with unreliable networks or APIs that may occasionally fail. With node-fetch-retry, developers can specify the number of retry attempts, delay between retries, and conditions under which retries should occur, making it a robust solution for improving the reliability of data fetching in Node.js applications.
While node-fetch-retry is a great option for adding retry logic to fetch requests, there are several alternatives in the ecosystem that provide similar functionalities. Here are a few noteworthy options:
axios-retry is a retry interceptor for the axios HTTP client. It allows developers to automatically retry requests that fail due to certain conditions, such as network errors or server responses that indicate a temporary issue. With axios-retry, you can easily configure the number of retries, delay intervals, and specific error conditions that trigger a retry, making it a powerful tool for enhancing the resilience of applications that rely on axios for HTTP requests.
fetch-retry is a simple wrapper around the native fetch API that adds retry functionality. It allows developers to specify the number of retries, delay between attempts, and conditions for retrying requests. This package is particularly useful for developers looking to enhance the native fetch API with minimal overhead while maintaining a straightforward API.
got is a powerful and flexible HTTP request library for Node.js that comes with built-in support for retries. It provides a rich set of features, including automatic retries on failure, timeout handling, and support for streams. If you are looking for a comprehensive HTTP client that includes retry logic along with many other advanced features, got is an excellent choice.
superagent-retry is a plugin for the superagent HTTP client that adds retry capabilities. It allows developers to automatically retry failed requests based on configurable conditions. If you are already using superagent in your application and need retry functionality, this plugin integrates seamlessly with the existing API.
superagent-retry is a plugin for the SuperAgent HTTP client that adds automatic retry functionality for failed requests. This package is particularly useful for handling transient errors, such as network issues or temporary server unavailability, allowing developers to enhance the resilience of their applications. While superagent-retry provides a robust solution for retrying requests, there are several alternatives in the ecosystem that offer similar functionality. Here are a few noteworthy options:
axios-retry is a retry plugin for Axios, a popular promise-based HTTP client. This library allows you to automatically retry failed requests based on configurable conditions, such as status codes or network errors. If you are already using Axios for your HTTP requests, axios-retry is a seamless way to add retry logic to your requests without changing your existing code structure.
fetch-retry is a simple wrapper around the Fetch API that adds retry capabilities. It allows developers to specify the number of retry attempts and conditions under which to retry requests. If you prefer using the Fetch API and want to add retry logic without much overhead, fetch-retry is a straightforward solution that integrates easily with existing fetch calls.
got is a powerful HTTP request library for Node.js that comes with built-in support for retries. It offers a rich set of features, including automatic retries on network errors and HTTP status codes, making it a comprehensive solution for managing HTTP requests in Node.js applications. If you are building a Node.js application and need a robust HTTP client with retry capabilities, got is an excellent choice.
retry-axios is another plugin for Axios that provides retry functionality. It allows you to specify retry conditions and delays between attempts, giving you fine-grained control over how requests are retried. If you are looking for a more customizable retry solution for Axios, retry-axios offers a flexible approach that can be tailored to your application's needs.
Axios plugin that intercepts failed requests and retries them whenever possible.
Installation
npm install axios-retry
Usage
// CommonJS
// const axiosRetry = require('axios-retry').default;
// ES6
import axiosRetry from 'axios-retry';
axiosRetry(axios, { retries: 3 });
axios.get('http://example.com/test') // The first request fails and the second returns 'ok'
.then(result => {
result.data; // 'ok'
});
// Exponential back-off retry delay between requests
axiosRetry(axios, { retryDelay: axiosRetry.exponentialDelay });
// Liner retry delay between requests
axiosRetry(axios, { retryDelay: axiosRetry.linearDelay() });
// Custom retry delay
axiosRetry(axios, { retryDelay: (retryCount) => {
return retryCount * 1000;
}});
// Works with custom axios instances
const client = axios.create({ baseURL: 'http://example.com' });
axiosRetry(client, { retries: 3 });
client.get('/test') // The first request fails and the second returns 'ok'
.then(result => {
result.data; // 'ok'
});
// Allows request-specific configuration
client
.get('/test', {
'axios-retry': {
retries: 0
}
})
.catch(error => { // The first request fails
error !== undefined
});
Note: Unless shouldResetTimeout is set, the plugin interprets the request timeout as a global value, so it is not used for each retry but for the whole request lifecycle.
Options
Name
Type
Default
Description
retries
Number
3
The number of times to retry before failing. 1 = One retry after first failure
retryCondition
Function
isNetworkOrIdempotentRequestError
A callback to further control if a request should be retried. By default, it retries if it is a network error or a 5xx error on an idempotent request (GET, HEAD, OPTIONS, PUT or DELETE).
shouldResetTimeout
Boolean
false
Defines if the timeout should be reset between retries
retryDelay
Function
function noDelay() { return 0; }
A callback to further control the delay in milliseconds between retried requests. By default there is no delay between retries. Another option is exponentialDelay (Exponential Backoff) or linearDelay. The function is passed retryCount and error.
onRetry
Function
function onRetry(retryCount, error, requestConfig) { return; }
A callback to notify when a retry is about to occur. Useful for tracing and you can any async process for example refresh a token on 401. By default nothing will occur. The function is passed retryCount, error, and requestConfig.
onMaxRetryTimesExceeded
Function
function onMaxRetryTimesExceeded(error, retryCount) { return; }
After all the retries are failed, this callback will be called with the last error before throwing the error.
validateResponse
Function | null
null
A callback to define whether a response should be resolved or rejected. If null is passed, it will fallback to the axios default (only 2xx status codes are resolved).