MCPcopy
hub / github.com/vercel/async-retry

github.com/vercel/async-retry @1.3.3 sqlite

repository ↗ · DeepWiki ↗ · release 1.3.3 ↗
6 symbols 14 edges 3 files 0 documented · 0%
README

async-retry

Retrying made simple, easy, and async.

Usage

// Packages
const retry = require('async-retry');
const fetch = require('node-fetch');

await retry(
  async (bail) => {
    // if anything throws, we retry
    const res = await fetch('https://google.com');

    if (403 === res.status) {
      // don't retry upon 403
      bail(new Error('Unauthorized'));
      return;
    }

    const data = await res.text();
    return data.substr(0, 500);
  },
  {
    retries: 5,
  }
);

API

retry(retrier : Function, opts : Object) => Promise
  • The supplied function can be async or not. In other words, it can be a function that returns a Promise or a value.
  • The supplied function receives two parameters
  • A Function you can invoke to abort the retrying (bail)
  • A Number identifying the attempt. The absolute first attempt (before any retries) is 1.
  • The opts are passed to node-retry. Read its docs
  • retries: The maximum amount of times to retry the operation. Default is 10.
  • factor: The exponential factor to use. Default is 2.
  • minTimeout: The number of milliseconds before starting the first retry. Default is 1000.
  • maxTimeout: The maximum number of milliseconds between two retries. Default is Infinity.
  • randomize: Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is true.
  • onRetry: an optional Function that is invoked after a new retry is performed. It's passed the Error that triggered it as a parameter.

Authors

Core symbols most depended-on inside this repo

retry
called by 10
lib/index.js
bail
called by 3
lib/index.js
onError
called by 2
lib/index.js
getRandomTitle
called by 1
examples/wikipedia.js
run
called by 0
lib/index.js
runAttempt
called by 0
lib/index.js

Shape

Function 6

Languages

TypeScript100%

Modules by API surface

lib/index.js5 symbols
examples/wikipedia.js1 symbols

Dependencies from manifests, versioned

ava3.15.0 · 1×
eslint7.32.0 · 1×
eslint-config-airbnb18.2.1 · 1×
eslint-config-prettier8.3.0 · 1×
eslint-plugin-import2.24.0 · 1×
eslint-plugin-jsx-a11y6.4.1 · 1×
eslint-plugin-react7.24.0 · 1×
lint-staged11.1.2 · 1×
node-fetch2.6.1 · 1×
pre-commit1.2.2 · 1×
prettier2.3.2 · 1×
retry0.13.1 · 1×

For agents

$ claude mcp add async-retry \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact