fix(cron): notify user when cron job is auto-disabled after repeated errors (openclaw#29098) thanks @ningding97

Verified:
- pnpm install --frozen-lockfile
- pnpm check
- pnpm test -- --run src/cron/service.runs-one-shot-main-job-disables-it.test.ts

Co-authored-by: ningding97 <17723822+ningding97@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
StingNing
2026-03-01 20:54:02 +08:00
committed by GitHub
parent 504c1f3607
commit 5b49cc4129
2 changed files with 15 additions and 0 deletions

View File

@@ -208,6 +208,19 @@ function recordScheduleComputeError(params: {
{ jobId: job.id, name: job.name, errorCount, err: errText },
"cron: auto-disabled job after repeated schedule errors",
);
// Notify the user so the auto-disable is not silent (#28861).
const notifyText = `⚠️ Cron job "${job.name}" has been auto-disabled after ${errorCount} consecutive schedule errors. Last error: ${errText}`;
state.deps.enqueueSystemEvent(notifyText, {
agentId: job.agentId,
sessionKey: job.sessionKey,
contextKey: `cron:${job.id}:auto-disabled`,
});
state.deps.requestHeartbeatNow({
reason: `cron:${job.id}:auto-disabled`,
agentId: job.agentId,
sessionKey: job.sessionKey,
});
} else {
state.deps.log.warn(
{ jobId: job.id, name: job.name, errorCount, err: errText },