niahere 0.2.49 → 0.2.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/scheduler.ts +12 -5
package/package.json
CHANGED
package/src/core/scheduler.ts
CHANGED
|
@@ -79,10 +79,10 @@ async function tick(): Promise<void> {
|
|
|
79
79
|
|
|
80
80
|
for (const job of dueJobs) {
|
|
81
81
|
if (!job.always && !isWithinActiveHours()) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
await Job.markRun(job.name, nextRun).catch(() => {});
|
|
85
|
-
}
|
|
82
|
+
try {
|
|
83
|
+
const nextRun = computeNextRun(job.scheduleType, job.schedule, config.timezone, new Date());
|
|
84
|
+
if (nextRun) await Job.markRun(job.name, nextRun).catch(() => {});
|
|
85
|
+
} catch {}
|
|
86
86
|
log.info({ job: job.name }, "scheduler: skipping — outside active hours");
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
@@ -95,7 +95,14 @@ async function tick(): Promise<void> {
|
|
|
95
95
|
log.error({ err, job: job.name }, "scheduler: job failed");
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
let nextRun: Date | null = null;
|
|
99
|
+
try {
|
|
100
|
+
nextRun = computeNextRun(job.scheduleType, job.schedule, config.timezone, new Date());
|
|
101
|
+
} catch (err) {
|
|
102
|
+
log.error({ err, job: job.name, schedule: job.schedule }, "scheduler: invalid schedule, disabling job");
|
|
103
|
+
await Job.update(job.name, { enabled: false }).catch(() => {});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
99
106
|
await Job.markRun(job.name, nextRun).catch((err) => {
|
|
100
107
|
log.error({ err, job: job.name }, "scheduler: failed to update next_run_at");
|
|
101
108
|
});
|