tim-kos/node-retry

Option to unref timers

satazor opened this issue · 6 comments

Use case:

I have a long running process that use retry in various places. This process intercepts SIGINT and SIGTERM to gracefully do some cleaning before exiting, closing sockets and stuff like that keep the event loop from emptying. Though, the process won't exit if there is a retry running.. and I have to wait for the whole timer duration before exiting.

To solve this we could add an unref (true/false) option so that the setTimeout's don't prevent the process from exiting. Would you be willing to add this functionality?

Looks good to me, with the exception that it breaks the API now for the RetryOperation initialization. It now awaits an object as the second parameter, whereas before you could use a boolean for retryForever.

Could you please add code that fixes this? Something like:

if (typeof options == 'boolean') {
   var retryForever = options;
   options = {
      retryForever: retryForever,
      unref: false
   }
}

Then I'll happily merge this. Thanks for the contribution!

<3

On Tue, Jan 26, 2016 at 9:27 AM, André Cruz notifications@github.com
wrote:

@tim-kos https://github.com/tim-kos done, I've simplified your
suggestion a bit:
https://github.com/tim-kos/node-retry/pull/27/files#diff-5fbd26cd639da16ee356ed75e5ff2334R2


Reply to this email directly or view it on GitHub
#26 (comment).

Cool! Can you please release a new version (perhaps a stable 1.0.0)? Thanks <3

Done!

On Tue, Jan 26, 2016 at 11:48 AM, André Cruz notifications@github.com
wrote:

Cool! Can you please release a new version? Thanks <3


Reply to this email directly or view it on GitHub
#26 (comment).