Skip to content

Clearing a timer inside of its callback breaks groups #30

@Informatic

Description

@Informatic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions