mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:57:40 +00:00
fix(cron): share isolated announce flow + harden cron scheduling/delivery (#11641)
* fix(cron): comprehensive cron scheduling and delivery fixes - Fix delivery target resolution for isolated agent cron jobs - Improve schedule parsing and validation - Add job retry logic and error handling - Enhance cron ops with better state management - Add timer improvements for more reliable cron execution - Add cron event type to protocol schema - Support cron events in heartbeat runner (skip empty-heartbeat check, use dedicated CRON_EVENT_PROMPT for relay) * fix: remove cron debug test and add changelog/docs notes (#11641) (thanks @tyler6204)
This commit is contained in:
@@ -49,17 +49,13 @@ export function computeNextRunAtMs(schedule: CronSchedule, nowMs: number): numbe
|
||||
timezone: resolveCronTimezone(schedule.tz),
|
||||
catch: false,
|
||||
});
|
||||
let cursor = nowMs;
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
const next = cron.nextRun(new Date(cursor));
|
||||
if (!next) {
|
||||
return undefined;
|
||||
}
|
||||
const nextMs = next.getTime();
|
||||
if (Number.isFinite(nextMs) && nextMs > nowMs) {
|
||||
return nextMs;
|
||||
}
|
||||
cursor += 1_000;
|
||||
// Use a tiny lookback (1ms) so croner doesn't skip the current second
|
||||
// boundary. Without this, a job updated at exactly its cron time would
|
||||
// be scheduled for the *next* matching time (e.g. 24h later for daily).
|
||||
const next = cron.nextRun(new Date(nowMs - 1));
|
||||
if (!next) {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
const nextMs = next.getTime();
|
||||
return Number.isFinite(nextMs) && nextMs >= nowMs ? nextMs : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user