bail should prevent any further calls to the retrier function
See original GitHub issueFrom 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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:14
Top Results From Across the Web
bail should prevent any further calls to the retrier function #69
Calling bail will immediately reject the promise returned by retry , but if the promise returned by the retirer function is then itself...
Read more >Why We Can't Go Backwards on Bail Reform
In 2019, the New York State Legislature passed a bail reform law that pushed New York's criminal legal system in the right direction....
Read more >Bail - How Courts Work
The purpose of bail is simply to ensure that defendants will appear for trial and all pretrial hearings for which they must be...
Read more >A Brief on Bail Practices - Office of Justice Programs
--Any person denied bailor release, should be entitled to review of his case after 72 hours of detention, and if. detentiDn is continued...
Read more >dog trainers for aggressive dogs
Aggressive behavior in dogs means any behavior preceding or including an attack. ... After a few weeks, your dog should stop attacking furniture...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve faced the same issue and for me it feels like an unexpected behaviour. Unfortunately it was not easy to catch until I’ve seen application logs that appeared far after the promise execution (bail).
I think that retries should be simply stopped after
bail
was called.Pattern provided in README example breaks TypeScript typings:
which leads to an awful type-casting e.g.
Is this actually still an issue? I wrote these Jest tests that pass, which suggest it works just fine: