Skip to content

Commit 6ab3277

Browse files
fix(server): a missed fixed-time slot shows as failed on its scheduled task
Fixes #30844 AI-assisted; verified with the tests and tools listed above.
1 parent b6766fc commit 6ab3277

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/server/src/scheduledTasks/ScheduledTaskService.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ export const layer = Layer.effect(
11461146
task: ScheduledTask,
11471147
now: DateTime.DateTime,
11481148
reason = "missed",
1149+
runError?: string,
11491150
) {
11501151
const next = nextRunAt(task, now);
11511152
yield* Effect.logInfo("Skipping schedule task run", {
@@ -1158,6 +1159,7 @@ export const layer = Layer.effect(
11581159
UPDATE scheduled_tasks
11591160
SET next_run_at = ${next},
11601161
updated_at = ${iso(now)}
1162+
${runError === undefined ? sql`` : sql`, last_run_status = 'failed', last_run_error = ${runError}`}
11611163
WHERE task_id = ${task.id}
11621164
`.pipe(
11631165
Effect.mapError((cause) =>
@@ -1202,7 +1204,12 @@ export const layer = Layer.effect(
12021204
({ task, dueAt }) =>
12031205
Effect.suspend(() =>
12041206
isMissedFixedTimeRun(task.schedule, dueAt, now)
1205-
? rescheduleMissedRun(task, now)
1207+
? rescheduleMissedRun(
1208+
task,
1209+
now,
1210+
"missed",
1211+
"Missed a scheduled run because the server was not running at that time.",
1212+
)
12061213
: runTask(task, "scheduled"),
12071214
).pipe(
12081215
Effect.catch((cause) =>

0 commit comments

Comments
 (0)