Unable to clear the current running timer and exit the retry loop
Braj-120 opened this issue · 4 comments
The stop method present in the module does not clear the current running timer. Hence it waits for the current running timer to complete, then executes the callback, in which the retry method causes the exit from the retry loop.
For ex, if the timeouts are set to 1, 2, 4, 8 and 16, and currently the retry loop is waiting for 16 seconds, then even if the stop method is called in between, the timer still continues for the 16 seconds, and executes the callback before exiting as retry method will cause the exit.
However, suggested behaviour should be that retry loop exits instantly. This behaviour is needed when the program needs to exit and the retry is stuck waiting in the retry loop.
Agreed! Nice find!
Would you like to PR this fix?
Ok, I will fix it and raise a PR asap.
So, How do you want the approach for this to be. Do I add this fix to the existing stop method as a bug fix, or do I add an additional method, which clears the timer as well as perform the current stop operation so that it does not break any thing in existing dependents?
From the docs:
Allows you to stop the operation being retried. Useful for aborting the operation on a fatal error etc.
I think the documentation and the intended use implies that the timer is also aborted. I think if you change the existing stop() function that will be ok. We'll make it a minor upgrade (major if we'd be 1.0 already) instead of a semver patch.