npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

promise-request-retry

v1.0.2

Published

Simple wrapper on request-promise for retry mechanism

Downloads

78,834

Readme

request-promise-retry

npm : promise-request-retry

npm version coverage status build status npm downloads

Simple wrapper on top of request-promise to replicate retry mechanism, i.e, it will try to reprocess the request till a valid response is obtained, or the number of retrys is exhausted. Supports all options from request-promise.

Usage

  • additional parameter retry needed in request-promise options.
  • retry supports boolean (defaults to 1 retry) and positive integer.
  • in order to ignore retry or use genericrequest-promise,just don't specify the retry parameter.

GET Request sample with retry

var rp = require('promise-request-retry');
var options = {
    uri: 'https://api.github.com/user/repos',
    qs: {
        access_token: 'xxxxx xxxxx' // -> uri + '?access_token=xxxxx%20xxxxx'
    },
    headers: {
        'User-Agent': 'Request-Promise'
    },
    json: true, // Automatically parses the JSON string in the response, 
    retry : 2, // will retry the call twice, in case of error.
    verbose_logging : false, // will log errors only, if set to be true, will log all actions
    accepted: [ 400, 404 ] // Accepted HTTP Status codes (will not retry if request response has any of these HTTP Status Code)
    delay: 2000 // will delay retries by 2000 ms.  The default is 100. 
    factor: 2 // will multiple the delay by the factor each time a retry is attempted. 
};

rp(options)
    .then(function (repos) {
        console.log('User has %d repos', repos.length);
    })
    .catch(function (err) {
        // API call failed...
    });
logging sample
2018-03-13T22:20:21.308Z - info: [request-promise-retry] calling http://adadadadad.com/ with retry 3
2018-03-13T22:20:21.899Z - info: [request-promise-retry] Encountered error Error: getaddrinfo ENOTFOUND adadadadad.com adadadadad.com:80 for GET request to http://adadadadad.com/, retry count 3
2018-03-13T22:20:21.904Z - info: [request-promise-retry] Encountered error Error: getaddrinfo ENOTFOUND adadadadad.com adadadadad.com:80 for GET request to http://adadadadad.com/, retry count 2
2018-03-13T22:20:21.907Z - info: [request-promise-retry] Encountered error Error: getaddrinfo ENOTFOUND adadadadad.com adadadadad.com:80 for GET request to http://adadadadad.com/, retry count 1

For rest of samples, please refer request-promise documentation.

Installation

npm install promise-request-retry

Test

npm test