From 5cbe6bf8f84d39ea5b237503724b2c74c10a86a7 Mon Sep 17 00:00:00 2001 From: lyzno1 <92089059+lyzno1@users.noreply.github.com> Date: Wed, 27 Aug 2025 18:20:09 +0800 Subject: [PATCH] fix(schedule): correct weekly frequency weekday calculation algorithm (#24641) --- .../utils/execution-time-calculator.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts b/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts index d228eb44e5..4459c22fdd 100644 --- a/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts +++ b/web/app/components/workflow/nodes/trigger-schedule/utils/execution-time-calculator.ts @@ -116,12 +116,22 @@ export const getNextExecutionTimes = (data: ScheduleTriggerNodeType, count: numb let weekOffset = 0 while (executionCount < count) { + let hasValidDays = false + for (const selectedDay of selectedDays) { if (executionCount >= count) break const targetDay = dayMap[selectedDay as keyof typeof dayMap] + if (targetDay === undefined) continue + + hasValidDays = true + + const currentDayOfWeek = userToday.getDay() + const daysUntilTarget = (targetDay - currentDayOfWeek + 7) % 7 + const adjustedDays = daysUntilTarget === 0 ? 7 : daysUntilTarget + const execution = new Date(userToday) - execution.setDate(userToday.getDate() + targetDay + (weekOffset * 7)) + execution.setDate(userToday.getDate() + adjustedDays + (weekOffset * 7)) execution.setHours(displayHour, Number.parseInt(minute), 0, 0) // Only add if execution time is in the future @@ -130,6 +140,8 @@ export const getNextExecutionTimes = (data: ScheduleTriggerNodeType, count: numb executionCount++ } } + + if (!hasValidDays) break weekOffset++ }