Developers Notes

My Journey as Software Architect

In Search of Async Retry

my current method to retry if error occured is this:

 
let tryCounter = 1;
const retryCount = 99;
let result = null;
let error = [];
while (tryCounter <= retryCount) {
let errContainer = null;
try {
result = await executeAsyncMethod();
break;
} catch (e) {
errContainer = e;
console.log('error');
}
tryCounter += 1;
if (tryCounter === retryCount) {
error.push(errContainer);
}
}

 

this is what i use:

node.js - nodejs retry function if failed X times - Stack Overflow
https://stackoverflow.com/questions/55031780/nodejs-retry-function-if-failed-x-times

 

 

References:

javascript - Promise Retry Design Patterns - Stack Overflow
https://stackoverflow.com/questions/38213668/promise-retry-design-patterns

node.js - recursive retry function in nodejs - Stack Overflow
https://stackoverflow.com/questions/52396265/recursive-retry-function-in-nodejs?noredirect=1&lq=1

javascript - how to handle connect error 5 times and create an exception? - Stack Overflow
https://stackoverflow.com/questions/47859951/how-to-handle-connect-error-5-times-and-create-an-exception/47861553#47861553

Javascript fetch, retry upon failure. - DEV Community 👩‍💻👨‍💻
https://dev.to/ycmjason/javascript-fetch-retry-upon-failure-3p6g

node.js - Retry a Promise resolution N times, with a delay between the attempts - Code Review Stack Exchange
https://codereview.stackexchange.com/questions/217199/retry-a-promise-resolution-n-times-with-a-delay-between-the-attempts

Async Retries - ITNEXT
https://itnext.io/blog-md-3f9801f99454

node.js - How can you retry after an exception in Javascript when using promises? - Stack Overflow
https://stackoverflow.com/questions/30471131/how-can-you-retry-after-an-exception-in-javascript-when-using-promises

A few general patterns for retries using promises
https://gist.github.com/briancavalier/842626

javascript - How to do repeated requests until one succeeds without blocking in node? - Stack Overflow
https://stackoverflow.com/questions/18581483/how-to-do-repeated-requests-until-one-succeeds-without-blocking-in-node

 Coly010/notry: Clean up code by removing try-catch-finally blocks! 🚀
https://github.com/Coly010/notry