Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
is-retry-allowed
Advanced tools
Check whether a request can be retried based on the `error.code`
The is-retry-allowed npm package is used to determine if a given error is transient and likely to be resolved by retrying the failed operation. It checks the error against a list of known transient errors and returns a boolean indicating whether a retry should be allowed.
Check if a retry is allowed for a given error
This feature allows you to pass an error object to the isRetryAllowed function, which returns true if the error is considered transient and retryable, or false otherwise.
const isRetryAllowed = require('is-retry-allowed');
const error = new Error('ECONNRESET');
const shouldRetry = isRetryAllowed(error);
console.log(shouldRetry); // Output: true
The retry package provides a set of functions for retrying asynchronous functions. It is more feature-rich than is-retry-allowed, offering a flexible approach to control the number of retries, timeouts, and the interval between retries.
Similar to retry, async-retry is a library for retrying a function which returns a Promise. It supports custom retry strategies and has a simple API, but it does not provide a built-in mechanism to determine if an error is retryable.
p-retry is a library for retrying promises with a configurable number of attempts. It is promise-based and allows for custom retry conditions, but unlike is-retry-allowed, it does not come with a predefined list of retryable errors.
Check whether a request can be retried based on the
error.code
$ npm install is-retry-allowed
import isRetryAllowed from 'is-retry-allowed';
isRetryAllowed({code: 'ETIMEDOUT'});
//=> true
isRetryAllowed({code: 'ENOTFOUND'});
//=> false
isRetryAllowed({});
//=> true
Type: Error | object
The .code
property, if it exists, will be used to determine whether retry is allowed.
FAQs
Check whether a request can be retried based on the `error.code`
The npm package is-retry-allowed receives a total of 5,212,118 weekly downloads. As such, is-retry-allowed popularity was classified as popular.
We found that is-retry-allowed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.