Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 9, 2024 via pnpm

retry 0.10.1

Abstraction for exponential and custom retry strategies for failed operations.
Package summary
Share
0
issues
1
license
1
MIT
Package created
13 May 2011
Version published
12 Dec 2016
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
retry@0.10.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of retry 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does retry do?

The retry package provides an abstraction for implementing exponential and custom retry strategies for failed operations in your Node.js programs. This npm package allows developers to automatically retry failing operations a specific number of times, with the frequency of retries following either a default exponential backoff strategy or a manually configured custom strategy.

How do you use retry?

The retry package can be utilized in a Node.js program after installation via npm using the command npm install retry. Below is an example code snippet on how to use this package:

var dns = require('dns');
var retry = require('retry');

function faultTolerantResolve(address, cb) {
  var operation = retry.operation();

  operation.attempt(function(currentAttempt) {
    dns.resolve(address, function(err, addresses) {
      if (operation.retry(err)) {
        return;
      }

      cb(err ? operation.mainError() : null, addresses);
    });
  });
}

faultTolerantResolve('nodejs.org', function(err, addresses) {
  console.log(err, addresses);
});

The above code tries to resolve a given DNS address using the dns.resolve function with a fault-tolerant approach. If the resolve operation fails, operation.retry(err) is called to retry the operation according to the retry strategy defined by the operation object. In this example, we use the default retry strategy, which retried failed operations 10 times with an exponential backoff. The retry behavior can be customized using an options object as shown below:

var operation = retry.operation({
  retries: 5,
  factor: 3,
  minTimeout: 1 * 1000,
  maxTimeout: 60 * 1000,
  randomize: true,
});

Where are the retry docs?

The documentation for the retry package is available in the README file of the project's GitHub repository. It provides a detailed overview of the API available as part of the package along with examples and explanations for all options used for retry strategies.

The link to the repository is https://github.com/tim-kos/node-retry where the README file is located at the root of the repository. The API documentation section includes explanations of all the methods such as retry.operation, retry.timeouts, retry.createTimeout, retry.wrap, and more. Additionally, specific use-cases and strategies related to retries, timeout calculations, and the exponential backoff approach are also documented in detail.