Skip to content
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

Clearing a timer inside of its callback breaks groups #30

Closed
Informatic opened this issue Sep 23, 2019 · 2 comments
Closed

Clearing a timer inside of its callback breaks groups #30

Informatic opened this issue Sep 23, 2019 · 2 comments
Labels

Comments

@Informatic
Copy link

Hey.

I just discovered an intersting case.

If timer is cleared from inside of its handler, _onDone/finished callback (which I assume is not even public...?) gets called twice, which in case of timers bound to groups removes last timer from its list of managed timers.

timers.splice(timers.indexOf(id), 1);

indexOf on second call here returns -1 (since id has already been removed)
Wrapping this call with simple if to verify timer is still there seems to fix the problem, though, this should be properly handled in timer code - I'm not using intervals in my code, but it looks like interval cleared in its handler called after interval.resume() might get rescheduled as well. That would need a separate test, I guess...

Minimal testcase follows:
https://gist.github.com/81e656a7f06276081cf148283500c49e

@Informatic
Copy link
Author

Just dropped a quick fix in my fork (and one that might fix additional untested issue I mentioned regarding intervals). Sadly I stumbled upon this bug during a very busy week so can't get proper tests done.
Informatic@e3b0b98

@fent
Copy link
Owner

fent commented Sep 24, 2019

thanks for the bug report! will push a fix out tonight

@fent fent added the bug label Sep 24, 2019
@fent fent closed this as completed in 71d41fb Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants