-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unref timers #11
Comments
I think unrefing the timeout timer by default would be a good idea. If there's wor going on in the timeout's execute that's keeping the process alive, we may as well shut down. That's here: cockatiel/src/TimeoutPolicy.ts Line 41 in ee47684
I don't think doing the same on the retry timer is good; if that was the case, a process could shut down instead of retrying on failure if the timer wasn't keeping the process alive. PR's would be welcome. |
The timer is cleared once the execution completes. Presumably the execution itself will keep the process alive. To clarify, are you suggesting that just in case the execution doesn't, but it does not complete either, you don't want the timer to keep the process alive?
Agreed. I just realized that the circuit breaker causes errors to be thrown while the circuit is open, so it doesn't have any timers. |
Ah, didn't notice that. Apologies, that's what I get for going through GH notifications before I have my 🍵 Indeed, the circuit breaker looks at the current time but doesn't have any timers--the test opening is done on the next call after the specified interval has past, not in the background. Looks like timeouts and retries are the only places we use |
Yea still figuring out how to compose all this stuff.
No, those are the only places I could find as well. |
Okay. Let me know there's actions to take on this issue, feel free to close it otherwise 🙂
I should get some diagrams in the docs to help with that. I've been sort of directing people to the Polly wiki for more in-depth info, but that's an extra hop that not everyone will make/notice. |
I'll try and get some PRs done on Monday. |
By default, unreference timers created by the TimeoutPolicy. Add an option to keep the timer referenced. Add an option when buliding a RetryPolicy to unreference the timer. Fixes connor4312#11.
I'm using Cockatiel to renew cryptographic keys from service A, in the background of service B. Service B also runs a server.
The retry and timeout policies (and, presumably, the circuit breaker, but I can't immediately see how this works) create timer objects. These keep the Node.js process alive.
Since I'm renewing keys in the background I'd rather the timers be unreferenced. This way, my process can shut down gracefully when the server is closed.
Currently if a renewal is stuck in a retry delay (or presumably a circuit breaker delay) my process won't shut down.
We could address this by adding an
unref
option in the policy creation arguments. It should default tofalse
, which would be the current behavior, but if set totrue
it would ensure all timers are unreferenced.Let me know if this is something you'd like and I can submit a PR.
The text was updated successfully, but these errors were encountered: