All Projects → vercel → Async Retry

vercel / Async Retry

Licence: mit
Retrying made simple, easy and async

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Async Retry

P Map
Map over promises concurrently
Stars: ✭ 639 (-49.37%)
Mutual labels:  async, await
Wx Promise Pro
✨强大、优雅的微信小程序异步库🚀
Stars: ✭ 762 (-39.62%)
Mutual labels:  async, await
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (-45.32%)
Mutual labels:  async, await
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+299.29%)
Mutual labels:  async, await
Modern Async
A modern JavaScript tooling library for asynchronous operations using async/await and promises
Stars: ✭ 31 (-97.54%)
Mutual labels:  async, await
Vue Skeleton Mvp
VueJs, Vuetify, Vue Router and Vuex skeleton MVP written on JavaScript using async/await built to work with API REST skeleton: https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton
Stars: ✭ 406 (-67.83%)
Mutual labels:  async, await
Awaitkit
The ES8 Async/Await control flow for Swift
Stars: ✭ 709 (-43.82%)
Mutual labels:  async, await
Async Techniques Python Course
Async Techniques and Examples in Python Course
Stars: ✭ 314 (-75.12%)
Mutual labels:  async, await
Koahub Demo
koahub+async/await+mysql
Stars: ✭ 15 (-98.81%)
Mutual labels:  async, await
Blockly Gamepad
A Blockly extension designed to develop games (made with love ❤)
Stars: ✭ 18 (-98.57%)
Mutual labels:  async, await
Asyncenumerable
Defines IAsyncEnumerable, IAsyncEnumerator, ForEachAsync(), ParallelForEachAsync(), and other useful stuff to use with async-await
Stars: ✭ 367 (-70.92%)
Mutual labels:  async, await
Breeze
Javascript async flow control manager
Stars: ✭ 38 (-96.99%)
Mutual labels:  async, await
P Iteration
Utilities that make array iteration easy when using async/await or Promises
Stars: ✭ 337 (-73.3%)
Mutual labels:  async, await
Micro Router
🚉 A tiny and functional router for Zeit's Micro
Stars: ✭ 621 (-50.79%)
Mutual labels:  async, await
Async Sema
Semaphore using `async` and `await`
Stars: ✭ 326 (-74.17%)
Mutual labels:  async, await
Asyncawaitbestpractices
Extensions for System.Threading.Tasks.Task and System.Threading.Tasks.ValueTask
Stars: ✭ 693 (-45.09%)
Mutual labels:  async, await
Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (-80.98%)
Mutual labels:  async, await
Genawaiter
Stackless generators on stable Rust.
Stars: ✭ 263 (-79.16%)
Mutual labels:  async, await
Ws Promise Client
PROJECT MOVED: https://github.com/kdex/ws-promise
Stars: ✭ 6 (-99.52%)
Mutual labels:  async, await
Csp
Communicating Sequential Processes in JavaScript
Stars: ✭ 33 (-97.39%)
Mutual labels:  async, await

async-retry

Code Style Join the community on Spectrum

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
    1. A Function you can invoke to abort the retrying (bail)
    2. 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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].