-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
From the example:
// 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 <---- don't immediately return here
throw new Error('Throw after bail');
}
const data = await res.text()
return data.substr(0, 500)
}, {
retries: 5
})Calling bail will immediately reject the promise returned by retry, but if the promise returned by the retirer function is then itself rejected, attempts will continue running in the background until e.g. the max retry count is reached.
This can be surprising and result in obscure bugs.
xenjke, przemyslaw-wlodek, pat-hanbury, mage-ua, nickluger and 9 morenickluger, kddsultan and rufreakde
Metadata
Metadata
Assignees
Labels
No labels