Socket
Socket
Sign inDemoInstall

retry-as-promised

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    retry-as-promised

Retry a failed promise


Version published
Weekly downloads
1.9M
decreased by-3.15%
Maintainers
1
Install size
36.7 kB
Created
Weekly downloads
 

Readme

Source

retry-as-promised

Retry promises when they fail

Installation

$ npm install --save retry-as-promised
$ yarn add retry-as-promised

Configuration

var retry = require('retry-as-promised').default;

var warningFn = function(msg){ someLoggingFunction(msg, 'notice'); };

// Will call the until max retries or the promise is resolved.
return retry(function (options) {
  // options.current, times callback has been called including this call
  return promise;
}, {
  max: 3, // maximum amount of tries
  timeout: 10000 // throw if no response or error within millisecond timeout, default: undefined,
  match: [ // Must match error signature (ala bluebird catch) to continue
    Sequelize.ConnectionError,
    'SQLITE_BUSY'
  ],
  backoffBase: 1000 // Initial backoff duration in ms. Default: 100,
  backoffExponent: 1.5 // Exponent to increase backoff each try. Default: 1.1
  report: warningFn, // the function used for reporting; must have a (string, object) argument signature, where string is the message that will passed in by retry-as-promised, and the object will be this configuration object + the $current property
  name:  'SourceX' // if user supplies string, it will be used when composing error/reporting messages; else if retry gets a callback, uses callback name in erroring/reporting; else (default) uses literal string 'unknown'
});

Tested with

  • Bluebird
  • Q

Keywords

FAQs

Last updated on 07 Feb 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc