fix(cron): recheck pending jobs before execution

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-14 17:48:10 +08:00
1 parent 02ca8f6558
commit 60b7c8cf3c
2 files changed
+88 -1

No files matched your search

+10 -1
View File
@@ -569,7 +569,16 @@ class CronService:
if j.enabled and j.state.next_run_at_ms and now >= j.state.next_run_at_ms
]
for job in due_jobs:
for candidate in due_jobs:
# Earlier callbacks may delete, disable, or reschedule later jobs.
job = self.get_job(candidate.id)
if (
job is None
or not job.enabled
or not job.state.next_run_at_ms
or job.state.next_run_at_ms > _now_ms()
):
continue
await self._execute_job(job)
self._save_store()