From 61a998cae33f0a1dae48e45fd53cf19b4535ac73 Mon Sep 17 00:00:00 2001 From: harald Date: Sat, 21 Feb 2026 07:36:03 +0100 Subject: [PATCH] fix(cron): correct false high-frequency warning for daily cron jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The frequency check compared two consecutive calls to next_run_for_schedule with now and now+1s, which returned the same next occurrence for daily schedules — making the interval appear as 0 minutes. Compare two consecutive occurrences instead. Co-Authored-By: Claude Opus 4.6 --- src/cron/scheduler.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cron/scheduler.rs b/src/cron/scheduler.rs index ce9c6c3..018ab13 100644 --- a/src/cron/scheduler.rs +++ b/src/cron/scheduler.rs @@ -218,11 +218,14 @@ fn warn_if_high_frequency_agent_job(job: &CronJob) { Schedule::Every { every_ms } => *every_ms < 5 * 60 * 1000, Schedule::Cron { .. } => { let now = Utc::now(); - match ( - next_run_for_schedule(&job.schedule, now), - next_run_for_schedule(&job.schedule, now + chrono::Duration::seconds(1)), - ) { - (Ok(a), Ok(b)) => (b - a).num_minutes() < 5, + match next_run_for_schedule(&job.schedule, now) { + Ok(first) => { + // Get the occurrence *after* the first one to measure the actual interval. + match next_run_for_schedule(&job.schedule, first) { + Ok(second) => (second - first).num_minutes() < 5, + _ => false, + } + } _ => false, } }