superagent
superagent copied to clipboard
retry async function not working
Hi if I implement retry with async callback function. Async sleep will not work. But if I do it this way:
.retry(3, (err) => {
if (err) {
log.error(err, module, 'Retrying request');
// sleep sync
// important: don't remove this, async solution will not work!!!
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2 * 1000);
return true;
}
return false;
})
All works. Does this look like good solution to you? Apart of it this is blocking worker thread.
PR welcome to fix this - perhaps start by adding at test that fails?