From 9c6c1243cf2764ca8a470ac50d6f77be908b6e1f Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 26 May 2020 22:35:25 +0300 Subject: [PATCH] More random --- src/Scheduler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Scheduler.ts b/src/Scheduler.ts index 3398018..76f16df 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -57,8 +57,9 @@ export class Scheduler { } private createUniqTaskTimer(seconds: number, name: string, args: Args = {}) { - this.scheduleUniqTask(name, args, timestamp() + seconds - 10); + const firstDelay = around(seconds - 10, 0.2); const intervalTime = around(seconds, 0.2) * 1000; + this.scheduleUniqTask(name, args, timestamp() + firstDelay); setInterval(() => this.scheduleUniqTask(name, args, timestamp()), intervalTime); }