Skip to content

Timer not cleaned up when cancelled. #15

@tegefaulkes

Description

@tegefaulkes

Specification

When calling cancel() on a Timer to clean it up, the underlying node timer is not cleared with clearTimeout() and the Timer promise never resolves or rejects. The prevents the process from ending until the timer delay has passed.

To reproduce this take the following steps.

  1. Create a Timer with 10 seconds delay.
  2. cancel the timer with any reason.
  3. check if the timer rejects with provided reason immediately.
  4. Check that the underlying node timer is cleaned up with clearTimeout(). This should be the case if the Timer rejected or resolved.
  5. Check that the process is not held open after the timer is cancelled.

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

  1. Check if Timer is properly cleaning up when cancelled.
  2. add tests checking this condition.
  3. Apply any fix if needed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions