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

推荐订阅源

MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
C
Check Point Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
腾讯CDC
GbyAI
GbyAI
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件

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(cron): repair stale future next-run slots (#78272) · ...
kevinslin · 2026-05-07 · via Recent Commits to openclaw:main

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

33

applyJobPatch,

44

createJob,

55

recomputeNextRuns,

6+

recomputeNextRunsForMaintenance,

67

resolveJobPayloadTextForMain,

78

} from "./service/jobs.js";

89

import type { CronServiceState } from "./service/state.js";

@@ -732,4 +733,216 @@ describe("recomputeNextRuns", () => {

732733

}

733734

expect(job.state.nextRunAtMs).toBe(now);

734735

});

736+737+

it("repairs future cron nextRunAtMs values that are not schedule slots", () => {

738+

const now = Date.parse("2026-05-05T12:00:00.000Z");

739+

const badFuture = Date.parse("2026-05-12T16:00:00.000Z");

740+

const expected = Date.parse("2026-05-05T13:00:00.000Z");

741+

const job: CronJob = {

742+

id: "daily-21-shanghai",

743+

name: "daily 21 shanghai",

744+

enabled: true,

745+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

746+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

747+

schedule: { kind: "cron", expr: "0 0 21 * * *", tz: "Asia/Shanghai", staggerMs: 0 },

748+

sessionTarget: "main",

749+

wakeMode: "now",

750+

payload: { kind: "systemEvent", text: "tick" },

751+

state: { nextRunAtMs: badFuture },

752+

};

753+

const state = {

754+

...createMockState(now),

755+

store: { version: 1 as const, jobs: [job] },

756+

} as CronServiceState;

757+758+

expect(recomputeNextRunsForMaintenance(state)).toBe(true);

759+

expect(job.state.nextRunAtMs).toBe(expected);

760+

});

761+762+

it("preserves valid future cron nextRunAtMs values during maintenance", () => {

763+

const now = Date.parse("2026-05-05T12:00:00.000Z");

764+

const validFuture = Date.parse("2026-05-05T13:00:00.000Z");

765+

const job: CronJob = {

766+

id: "daily-valid-future",

767+

name: "daily valid future",

768+

enabled: true,

769+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

770+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

771+

schedule: { kind: "cron", expr: "0 0 21 * * *", tz: "Asia/Shanghai", staggerMs: 0 },

772+

sessionTarget: "main",

773+

wakeMode: "now",

774+

payload: { kind: "systemEvent", text: "tick" },

775+

state: { nextRunAtMs: validFuture },

776+

};

777+

const state = {

778+

...createMockState(now),

779+

store: { version: 1 as const, jobs: [job] },

780+

} as CronServiceState;

781+782+

expect(recomputeNextRunsForMaintenance(state)).toBe(false);

783+

expect(job.state.nextRunAtMs).toBe(validFuture);

784+

});

785+786+

it("repairs future cron nextRunAtMs values that would fire before the next schedule slot", () => {

787+

const now = Date.parse("2026-05-05T12:00:00.000Z");

788+

const tooEarly = Date.parse("2026-05-05T12:30:00.000Z");

789+

const expected = Date.parse("2026-05-05T13:00:00.000Z");

790+

const job: CronJob = {

791+

id: "daily-too-early",

792+

name: "daily too early",

793+

enabled: true,

794+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

795+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

796+

schedule: { kind: "cron", expr: "0 0 21 * * *", tz: "Asia/Shanghai", staggerMs: 0 },

797+

sessionTarget: "main",

798+

wakeMode: "now",

799+

payload: { kind: "systemEvent", text: "tick" },

800+

state: { nextRunAtMs: tooEarly },

801+

};

802+

const state = {

803+

...createMockState(now),

804+

store: { version: 1 as const, jobs: [job] },

805+

} as CronServiceState;

806+807+

expect(recomputeNextRunsForMaintenance(state)).toBe(true);

808+

expect(job.state.nextRunAtMs).toBe(expected);

809+

});

810+811+

it("preserves deferred agent-turn cron nextRunAtMs values before the next natural slot", () => {

812+

const now = Date.parse("2026-05-05T12:00:00.000Z");

813+

const deferred = Date.parse("2026-05-05T12:02:00.000Z");

814+

const job: CronJob = {

815+

id: "daily-deferred-agent-turn",

816+

name: "daily deferred agent turn",

817+

enabled: true,

818+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

819+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

820+

schedule: { kind: "cron", expr: "0 0 21 * * *", tz: "Asia/Shanghai", staggerMs: 0 },

821+

sessionTarget: "isolated",

822+

wakeMode: "now",

823+

payload: { kind: "agentTurn", message: "tick" },

824+

state: { nextRunAtMs: deferred },

825+

};

826+

const state = {

827+

...createMockState(now),

828+

store: { version: 1 as const, jobs: [job] },

829+

} as CronServiceState;

830+831+

expect(recomputeNextRunsForMaintenance(state)).toBe(false);

832+

expect(job.state.nextRunAtMs).toBe(deferred);

833+

});

834+835+

it("preserves cron retry backoff nextRunAtMs values during maintenance", () => {

836+

const now = Date.parse("2025-12-13T04:02:00.000Z");

837+

const retryAt = Date.parse("2025-12-13T04:10:00.000Z");

838+

const job: CronJob = {

839+

id: "backoff-pending",

840+

name: "backoff pending",

841+

enabled: true,

842+

createdAtMs: Date.parse("2025-12-10T12:00:00.000Z"),

843+

updatedAtMs: Date.parse("2025-12-13T04:01:10.000Z"),

844+

schedule: { kind: "cron", expr: "* * * * *", tz: "UTC" },

845+

sessionTarget: "main",

846+

wakeMode: "next-heartbeat",

847+

payload: { kind: "systemEvent", text: "do not run during backoff" },

848+

state: {

849+

nextRunAtMs: retryAt,

850+

lastRunAtMs: Date.parse("2025-12-13T04:01:00.000Z"),

851+

lastStatus: "error",

852+

consecutiveErrors: 4,

853+

},

854+

};

855+

const state = {

856+

...createMockState(now),

857+

store: { version: 1 as const, jobs: [job] },

858+

} as CronServiceState;

859+860+

expect(recomputeNextRunsForMaintenance(state)).toBe(false);

861+

expect(job.state.nextRunAtMs).toBe(retryAt);

862+

});

863+864+

it("preserves cron retry backoff nextRunAtMs values from the run end time", () => {

865+

const now = Date.parse("2025-12-13T04:10:00.000Z");

866+

const retryAt = Date.parse("2025-12-13T04:20:30.000Z");

867+

const job: CronJob = {

868+

id: "backoff-from-ended-at",

869+

name: "backoff from ended at",

870+

enabled: true,

871+

createdAtMs: Date.parse("2025-12-10T12:00:00.000Z"),

872+

updatedAtMs: Date.parse("2025-12-13T04:05:30.000Z"),

873+

schedule: { kind: "cron", expr: "* * * * *", tz: "UTC" },

874+

sessionTarget: "main",

875+

wakeMode: "next-heartbeat",

876+

payload: { kind: "systemEvent", text: "preserve run-end retry backoff" },

877+

state: {

878+

nextRunAtMs: retryAt,

879+

lastRunAtMs: Date.parse("2025-12-13T04:01:30.000Z"),

880+

lastDurationMs: 4 * 60_000,

881+

lastStatus: "error",

882+

consecutiveErrors: 4,

883+

},

884+

};

885+

const state = {

886+

...createMockState(now),

887+

store: { version: 1 as const, jobs: [job] },

888+

} as CronServiceState;

889+890+

expect(recomputeNextRunsForMaintenance(state)).toBe(false);

891+

expect(job.state.nextRunAtMs).toBe(retryAt);

892+

});

893+894+

it("repairs stale future cron nextRunAtMs values after error backoff has elapsed", () => {

895+

const now = Date.parse("2026-05-05T12:00:00.000Z");

896+

const badFuture = Date.parse("2026-05-12T16:00:00.000Z");

897+

const expected = Date.parse("2026-05-05T13:00:00.000Z");

898+

const job: CronJob = {

899+

id: "daily-expired-error",

900+

name: "daily expired error",

901+

enabled: true,

902+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

903+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

904+

schedule: { kind: "cron", expr: "0 0 21 * * *", tz: "Asia/Shanghai", staggerMs: 0 },

905+

sessionTarget: "main",

906+

wakeMode: "now",

907+

payload: { kind: "systemEvent", text: "tick" },

908+

state: {

909+

nextRunAtMs: badFuture,

910+

lastRunAtMs: Date.parse("2026-05-04T00:00:00.000Z"),

911+

lastStatus: "error",

912+

consecutiveErrors: 1,

913+

},

914+

};

915+

const state = {

916+

...createMockState(now),

917+

store: { version: 1 as const, jobs: [job] },

918+

} as CronServiceState;

919+920+

expect(recomputeNextRunsForMaintenance(state)).toBe(true);

921+

expect(job.state.nextRunAtMs).toBe(expected);

922+

});

923+924+

it("does not throw while probing malformed cron schedules with future nextRunAtMs", () => {

925+

const now = Date.parse("2026-05-05T12:00:00.000Z");

926+

const future = Date.parse("2026-05-12T16:00:00.000Z");

927+

const job: CronJob = {

928+

id: "malformed-future",

929+

name: "malformed future",

930+

enabled: true,

931+

createdAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

932+

updatedAtMs: Date.parse("2026-05-05T00:00:00.000Z"),

933+

schedule: { kind: "cron", expr: "not a valid cron", tz: "UTC" },

934+

sessionTarget: "main",

935+

wakeMode: "now",

936+

payload: { kind: "systemEvent", text: "tick" },

937+

state: { nextRunAtMs: future },

938+

};

939+

const state = {

940+

...createMockState(now),

941+

store: { version: 1 as const, jobs: [job] },

942+

} as CronServiceState;

943+944+

expect(() => recomputeNextRunsForMaintenance(state)).not.toThrow();

945+

expect(job.state.nextRunAtMs).toBe(future);

946+

expect(job.state.scheduleErrorCount).toBeUndefined();

947+

});

735948

});