From c8b455b8e22e34d605eb858895bd487376bf8c4f Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 4 Sep 2020 15:18:41 +0000 Subject: [PATCH] fix(core): update --- ts/smarttime.classes.cronmanager.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ts/smarttime.classes.cronmanager.ts b/ts/smarttime.classes.cronmanager.ts index 6ad80f7..fd59c01 100644 --- a/ts/smarttime.classes.cronmanager.ts +++ b/ts/smarttime.classes.cronmanager.ts @@ -46,10 +46,17 @@ export class CronManager { nextRunningCronjob = cronJob; } } - this.executionTimeout = new plugins.smartdelay.Timeout(nextRunningCronjob.getTimeToNextExecution()); - console.log( - `Next CronJob scheduled in ${this.executionTimeout.getTimeLeft()} milliseconds` - ); + if (nextRunningCronjob) { + this.executionTimeout = new plugins.smartdelay.Timeout(nextRunningCronjob.getTimeToNextExecution()); + console.log( + `Next CronJob scheduled in ${this.executionTimeout.getTimeLeft()} milliseconds` + ); + } else { + this.executionTimeout = new plugins.smartdelay.Timeout(1000); + console.log('no cronjobs specified! Checking again in 1 second'); + } + + await this.executionTimeout.promise; } while (this.status === 'started'); };