vercel / async-retry

Retrying made simple, easy and async
https://npmjs.com/async-retry
MIT License
1.85k stars 53 forks source link

Feature: set a timeout for the entire retry operation #73

Open fastfrwrd opened 4 years ago

fastfrwrd commented 4 years ago

I find myself doing this a lot when using async-retry:

await Promise.race(
  retry(/* ... */),
  new Promise((_, reject) => {
    setTimeout(() => {
      reject(new Error('FAILED to complete async retry in less than 1 minute'))
    }, 60000)
  }),
)

It would be awesome if there were a clean way to provide an option (retryTimeout?) that allowed you to say ("time out after the retry went for this long, regardless of the attempt number").