Do not allow shorter polling-times than 1 minute

This commit is contained in:
Jan Oberhauser 2020-11-12 12:42:04 +01:00
parent a800a84078
commit e327bfcb91

View file

@ -127,7 +127,7 @@ export class ActiveWorkflows {
for (const item of pollTimes.item) { for (const item of pollTimes.item) {
cronTime = []; cronTime = [];
if (item.mode === 'custom') { if (item.mode === 'custom') {
cronTimes.push(item.cronExpression as string); cronTimes.push((item.cronExpression as string).trim());
continue; continue;
} }
if (item.mode === 'everyMinute') { if (item.mode === 'everyMinute') {
@ -178,6 +178,11 @@ export class ActiveWorkflows {
// Start the cron-jobs // Start the cron-jobs
const cronJobs: CronJob[] = []; const cronJobs: CronJob[] = [];
for (const cronTime of cronTimes) { for (const cronTime of cronTimes) {
const cronTimeParts = cronTime.split(' ');
if (cronTimeParts.length > 0 && cronTimeParts[0].includes('*')) {
throw new Error('The polling interval is too short. It has to be at least a minute!');
}
cronJobs.push(new CronJob(cronTime, executeTrigger, undefined, true, timezone)); cronJobs.push(new CronJob(cronTime, executeTrigger, undefined, true, timezone));
} }