惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
The Cloudflare Blog
IT之家
IT之家
V
V2EX
雷峰网
雷峰网
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
A
About on SuperTechFans
B
Blog
月光博客
月光博客
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: honor cron backoff from run end · openclaw/openclaw@...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

@@ -57,6 +57,7 @@ import {

5757

nextWakeAtMs,

5858

recomputeNextRunsForMaintenance,

5959

recordScheduleComputeError,

60+

resolveJobErrorBackoffUntilMs,

6061

resolveJobPayloadTextForMain,

6162

} from "./jobs.js";

6263

import { locked } from "./locked.js";

@@ -1467,6 +1468,7 @@ export async function onTimer(state: CronServiceState) {

14671468

}

1468146914691470

function isRunnableJob(params: {

1471+

state: CronServiceState;

14701472

job: CronJob;

14711473

nowMs: number;

14721474

skipJobIds?: ReadonlySet<string>;

@@ -1504,14 +1506,14 @@ function isRunnableJob(params: {

15041506

return false;

15051507

}

15061508

const next = job.state.nextRunAtMs;

1509+

if (isErrorBackoffPending(params.state, job, nowMs)) {

1510+

// Error retry windows are anchored at run end; persisted start-based

1511+

// retry timestamps from older state must not bypass active backoff.

1512+

return false;

1513+

}

15071514

if (hasScheduledNextRunAtMs(next) && nowMs >= next) {

15081515

return true;

15091516

}

1510-

if (hasScheduledNextRunAtMs(next) && next > nowMs && isErrorBackoffPending(job, nowMs)) {

1511-

// Respect active retry backoff windows on restart, but allow missed-slot

1512-

// replay once the backoff window has elapsed.

1513-

return false;

1514-

}

15151517

if (!params.allowCronMissedRunByLastRun || job.schedule.kind !== "cron") {

15161518

return false;

15171519

}

@@ -1532,20 +1534,15 @@ function isRunnableJob(params: {

15321534

return previousRunAtMs > lastRunAtMs;

15331535

}

153415361535-

function isErrorBackoffPending(job: CronJob, nowMs: number): boolean {

1537+

function isErrorBackoffPending(state: CronServiceState, job: CronJob, nowMs: number): boolean {

15361538

if (job.schedule.kind === "at" || job.state.lastStatus !== "error") {

15371539

return false;

15381540

}

1539-

const lastRunAtMs = job.state.lastRunAtMs;

1540-

if (typeof lastRunAtMs !== "number" || !Number.isFinite(lastRunAtMs)) {

1541-

return false;

1542-

}

1543-

const consecutiveErrorsRaw = job.state.consecutiveErrors;

1544-

const consecutiveErrors =

1545-

typeof consecutiveErrorsRaw === "number" && Number.isFinite(consecutiveErrorsRaw)

1546-

? Math.max(1, Math.floor(consecutiveErrorsRaw))

1547-

: 1;

1548-

return nowMs < lastRunAtMs + errorBackoffMs(consecutiveErrors);

1541+

const backoffUntilMs = resolveJobErrorBackoffUntilMs(

1542+

job,

1543+

state.deps.cronConfig?.retry?.backoffMs ?? DEFAULT_ERROR_BACKOFF_SCHEDULE_MS,

1544+

);

1545+

return backoffUntilMs !== undefined && nowMs < backoffUntilMs;

15491546

}

1550154715511548

function collectRunnableJobs(

@@ -1562,6 +1559,7 @@ function collectRunnableJobs(

15621559

}

15631560

return state.store.jobs.filter((job) =>

15641561

isRunnableJob({

1562+

state,

15651563

job,

15661564

nowMs,

15671565

skipJobIds: opts?.skipJobIds,

@@ -1571,6 +1569,55 @@ function collectRunnableJobs(

15711569

);

15721570

}

157315711572+

function deferPendingBackoffMissedCronSlots(

1573+

state: CronServiceState,

1574+

nowMs: number,

1575+

opts?: { skipJobIds?: ReadonlySet<string> },

1576+

): boolean {

1577+

if (!state.store) {

1578+

return false;

1579+

}

1580+

let changed = false;

1581+

for (const job of state.store.jobs) {

1582+

if (

1583+

!isJobEnabled(job) ||

1584+

job.schedule.kind !== "cron" ||

1585+

opts?.skipJobIds?.has(job.id) ||

1586+

typeof job.state.runningAtMs === "number"

1587+

) {

1588+

continue;

1589+

}

1590+

const backoffUntilMs = resolveJobErrorBackoffUntilMs(

1591+

job,

1592+

state.deps.cronConfig?.retry?.backoffMs ?? DEFAULT_ERROR_BACKOFF_SCHEDULE_MS,

1593+

);

1594+

if (backoffUntilMs === undefined || nowMs >= backoffUntilMs) {

1595+

continue;

1596+

}

1597+

let previousRunAtMs: number | undefined;

1598+

try {

1599+

previousRunAtMs = computeJobPreviousRunAtMs(job, nowMs);

1600+

} catch {

1601+

continue;

1602+

}

1603+

const lastRunAtMs = job.state.lastRunAtMs;

1604+

if (

1605+

typeof previousRunAtMs !== "number" ||

1606+

!Number.isFinite(previousRunAtMs) ||

1607+

typeof lastRunAtMs !== "number" ||

1608+

!Number.isFinite(lastRunAtMs) ||

1609+

previousRunAtMs <= lastRunAtMs

1610+

) {

1611+

continue;

1612+

}

1613+

if (job.state.nextRunAtMs !== backoffUntilMs) {

1614+

job.state.nextRunAtMs = backoffUntilMs;

1615+

changed = true;

1616+

}

1617+

}

1618+

return changed;

1619+

}

1620+15741621

export async function runMissedJobs(

15751622

state: CronServiceState,

15761623

opts?: { skipJobIds?: ReadonlySet<string>; deferAgentTurnJobs?: boolean },

@@ -1599,12 +1646,18 @@ async function planStartupCatchup(

15991646

}

1600164716011648

const now = state.deps.nowMs();

1649+

const deferredBackoffMissedSlot = deferPendingBackoffMissedCronSlots(state, now, {

1650+

skipJobIds: opts?.skipJobIds,

1651+

});

16021652

const missed = collectRunnableJobs(state, now, {

16031653

skipJobIds: opts?.skipJobIds,

16041654

skipAtIfAlreadyRan: true,

16051655

allowCronMissedRunByLastRun: true,

16061656

});

16071657

if (missed.length === 0) {

1658+

if (deferredBackoffMissedSlot) {

1659+

await persist(state);

1660+

}

16081661

return { candidates: [], deferredJobs: [] };

16091662

}

16101663

const sorted = missed.toSorted(