# retry-as-promised

> Retry a failed promise

Latest version **7.1.1** (published 2025-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install retry-as-promised
pnpm add retry-as-promised
yarn add retry-as-promised
bun add retry-as-promised
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.1.1 |
| Published | 2025-02-27 |
| First published | 2015-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 58 |
| Author | Mick Hansen |
| Maintainers | mickhansen |
| Keywords | retry, promise, bluebird |

## Links

- npm: https://www.npmjs.com/package/retry-as-promised
- Repository: https://github.com/mickhansen/retry-as-promised
- Issues: https://github.com/mickhansen/retry-as-promised/issues
- npm.io page: https://npm.io/package/retry-as-promised

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 7.1.1 (latest) — 2025-02-27
- 7.1.0 — 2025-02-25
- 7.0.4 — 2023-02-07
- 7.0.3 — 2022-12-08
- 7.0.2 — 2022-12-08
- 7.0.1 — 2022-12-06
- 7.0.0 — 2022-12-06
- 6.1.0 — 2022-09-02
- 6.0.0 — 2022-06-24
- 5.0.0 — 2021-12-17
- 4.0.0 — 2021-09-07
- 3.2.0 — 2019-03-07
- 3.1.0 — 2018-10-23
- 3.0.0 — 2018-06-04
- 2.3.2 — 2017-10-30
- … 10 more at https://npm.io/package/retry-as-promised/versions

## README

# retry-as-promised

Retry promises when they fail

## Installation

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

## Configuration

```js
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
  backoffJitter: 150 // Amount of randomized jitter in ms to add to retry interval to spread retries out over time. Default: 0.0.
  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

---
_Source: https://npm.io/package/retry-as-promised · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
