-
Notifications
You must be signed in to change notification settings - Fork 0
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
Timer not cleaned up when cancelled. #15
Comments
Should be a bug template not feature template. |
This is an issue tracking the but and fix. I've looked into this more, tests do test the proper behaviour when cancelling. But when we set
I think the intention here is if the handler is settling then we let it finish. BUT, if the timer has been created but hasn't timed out yet then the What I'd expect a
diff --git a/src/Timer.ts b/src/Timer.ts
index f28d84d..8127a60 100644
--- a/src/Timer.ts
+++ b/src/Timer.ts
@@ -315,7 +315,7 @@ class Timer<T = void>
protected async reject(reason?: any): Promise<void> {
if (
- (this.lazy && (this._status == null || this._status === 'settling')) ||
+ (this.lazy && this._status === 'settling') ||
this._status === 'settled'
) {
return;
It's a simple fix, but the latest version of this is using ESM now. So even if I fix staging I can't do a release the other repos can use. |
Do the fix by branching off when esm wasn't done and just do a fix there and release. I did the same for js-async-init. |
The purpose of the lazy is to avoid automatic rejection. To allow the handler to decide what to do. |
Yes if lazy is true and cancel is done, it should definitely cancel it. It's a bug. But I don't think the semantics of lazy should change. |
Branch off from ba97282 and release as 1.1.2 if you got a fix. |
Fixed with the release of |
So now when you cancel a lazy timer, but it hasn't executed the handler yet, then the timer is immediately rejected with the cancellation reason. We will need cherry-pick this feature into staging. Can you try that? I need to reopen until it's also part of mainline. |
Cherry pick only the change from feature-eager-cancellation, but not the release of 1.1.2, that will always live on in an orphaned branch. |
Cherry picked and worked e29b60e |
Specification
When calling
cancel()
on aTimer
to clean it up, the underlying node timer is not cleared withclearTimeout()
and theTimer
promise never resolves or rejects. The prevents the process from ending until the timer delay has passed.To reproduce this take the following steps.
Timer
with 10 seconds delay.clearTimeout()
. This should be the case if theTimer
rejected or resolved.I haven't tested this problem in this code base yet. It seems odd that this would be a problem or hasn't been tested. There may be something weird going on.
Additional context
MatrixAI/Polykey#585
Tasks
Timer
is properly cleaning up when cancelled.The text was updated successfully, but these errors were encountered: