You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constpRetry=require('p-retry');constdelay=require('delay');construn=async()=>{ ... };(async()=>{constresult=awaitpRetry(run,{onFailedAttempt: asyncerror=>{console.log('Waiting for 1 second before retrying');awaitdelay(1000);}});})();
Without knowing the retry module's features, a user may expect that this code would retry the run function every 1 second. This is not accurate as the retry module has an exponential delay function where, by default, it begins with a 1 second delay in between the first two tries and then multiplies 1 second by 2^(number of tries). The code provided then waits a single second before the retry module's delay between tries executes.
Ideally, this example should be removed since it could lead to confusion for new users of the library.
The text was updated successfully, but these errors were encountered:
I was just trying to write a test and was surprised to find that my retry was taking almost exactly 1000 ms longer than I expected.
I don't think trying to adding an explicit delay to the onFailedAttempt() is the correct solution here. I think documenting the options pass-through to retry is the correct strategy. For instance:
Additionally, because the retry module is not using arrow functions, it ends up rebinding 'this', which I didn't notice in my initial implementation, and so my delay function was getting undefined as an argument.
The way I'm suggesting avoids that problem, but you might want to work that into any other examples, if for no other reason to signal to people "hey this bit is tricky".
In the README.md, the following code exists:
Without knowing the retry module's features, a user may expect that this code would retry the
run
function every 1 second. This is not accurate as the retry module has an exponential delay function where, by default, it begins with a 1 second delay in between the first two tries and then multiplies 1 second by 2^(number of tries). The code provided then waits a single second before the retry module's delay between tries executes.Ideally, this example should be removed since it could lead to confusion for new users of the library.
The text was updated successfully, but these errors were encountered: