diff --git a/packages/plugins/workflow/src/server/triggers/schedule.ts b/packages/plugins/workflow/src/server/triggers/schedule.ts index 845eb4675..37058e1c8 100644 --- a/packages/plugins/workflow/src/server/triggers/schedule.ts +++ b/packages/plugins/workflow/src/server/triggers/schedule.ts @@ -51,11 +51,11 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, { } if (repeat) { - if (typeof repeat === 'number' - && repeat > this.cacheCycle - && (timestamp - startTime) % repeat > this.cacheCycle - ) { - return false; + if (typeof repeat === 'number') { + const next = timestamp - (timestamp - startTime) % repeat + repeat; + if (next <= timestamp || next > timestamp + this.cacheCycle) { + return false; + } } if (endsOn) { @@ -77,7 +77,6 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, { const timestamp = now.getTime(); // NOTE: align to second start const startTime = parseDateWithoutMs(startsOn); - if (!startTime || startTime > timestamp) { return; } @@ -498,7 +497,7 @@ export default class ScheduleTrigger extends Trigger { const should = await this.shouldCache(workflow, now); if (should) { - console.log('caching schedule workflow:', workflow.id); + this.plugin.app.logger.info('caching scheduled workflow will run in next minute:', workflow.id); } this.setCache(workflow, !should);