From e3b8073c8293123f4d493aac6967d77cb2e286d9 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Mon, 9 Sep 2024 14:22:41 +0700 Subject: [PATCH] [core] force null timeout and interval --- src/utils/SingleDelayedJobRunner.ts | 3 ++- src/utils/SinglePeriodicJobRunner.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/SingleDelayedJobRunner.ts b/src/utils/SingleDelayedJobRunner.ts index 3312fc56..bc086156 100644 --- a/src/utils/SingleDelayedJobRunner.ts +++ b/src/utils/SingleDelayedJobRunner.ts @@ -30,10 +30,10 @@ export class SingleDelayedJobRunner { } this.timeout = setTimeout(() => { + this.timeout = null; this.logger.debug(`Running job...`); fn().finally(() => { this.logger.debug(`Job finished`); - this.timeout = null; }); }, this.timeoutMs); this.logger.info(`Job scheduled with timeout ${this.timeoutMs} ms`); @@ -42,6 +42,7 @@ export class SingleDelayedJobRunner { cancel() { clearTimeout(this.timeout); + this.timeout = null; this.logger.info(`Job cancelled`); } diff --git a/src/utils/SinglePeriodicJobRunner.ts b/src/utils/SinglePeriodicJobRunner.ts index d863b382..27d9dd7a 100644 --- a/src/utils/SinglePeriodicJobRunner.ts +++ b/src/utils/SinglePeriodicJobRunner.ts @@ -51,6 +51,7 @@ export class SinglePeriodicJobRunner { stop() { clearInterval(this.interval); + this.interval = null; this.logger.info(`Job stopped`); }