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

推荐订阅源

B
Blog
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
博客园 - 叶小钗
J
Java Code Geeks
博客园 - 聂微东
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
美团技术团队
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
罗磊的独立博客
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
小众软件
小众软件

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): preserve startup overflow catch-up deferrals i...
yetval · 2026-06-17 · via Recent Commits to openclaw:main
1+

import { describe, expect, it, vi } from "vitest";

2+

import { setupCronServiceSuite } from "./service.test-harness.js";

3+

import { start } from "./service/ops.js";

4+

import { createCronServiceState } from "./service/state.js";

5+

import { saveCronStore } from "./store.js";

6+

import type { CronJob } from "./types.js";

7+8+

const { logger: noopLogger, makeStorePath } = setupCronServiceSuite({

9+

prefix: "openclaw-cron-overflow-",

10+

baseTimeIso: "2025-12-13T17:00:00.000Z",

11+

});

12+13+

describe("CronService startup catch-up repair scoping", () => {

14+

function createHourlyCronJob(id: string, nextRunAtMs: number): CronJob {

15+

return {

16+

id,

17+

name: `job-${id}`,

18+

enabled: true,

19+

createdAtMs: nextRunAtMs - 60_000,

20+

updatedAtMs: nextRunAtMs - 60_000,

21+

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

22+

sessionTarget: "main",

23+

wakeMode: "next-heartbeat",

24+

payload: { kind: "systemEvent", text: `tick-${id}` },

25+

state: { nextRunAtMs },

26+

};

27+

}

28+29+

function createDailyCronJob(id: string, nextRunAtMs: number): CronJob {

30+

return {

31+

id,

32+

name: `job-${id}`,

33+

enabled: true,

34+

createdAtMs: nextRunAtMs - 60_000,

35+

updatedAtMs: nextRunAtMs - 60_000,

36+

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

37+

sessionTarget: "main",

38+

wakeMode: "next-heartbeat",

39+

payload: { kind: "systemEvent", text: `tick-${id}` },

40+

state: { nextRunAtMs },

41+

};

42+

}

43+44+

it("keeps the overflow daily-cron catch-up deferral after start()'s maintenance pass", async () => {

45+

const store = await makeStorePath();

46+

const startNow = Date.parse("2025-12-13T17:00:00.000Z");

47+

const tomorrowNaturalSlot = Date.parse("2025-12-14T09:00:00.000Z");

48+49+

await saveCronStore(store.storePath, {

50+

version: 1,

51+

jobs: [

52+

createHourlyCronJob("hourly-0", Date.parse("2025-12-13T03:00:00.000Z")),

53+

createHourlyCronJob("hourly-1", Date.parse("2025-12-13T04:00:00.000Z")),

54+

createHourlyCronJob("hourly-2", Date.parse("2025-12-13T05:00:00.000Z")),

55+

createHourlyCronJob("hourly-3", Date.parse("2025-12-13T06:00:00.000Z")),

56+

createHourlyCronJob("hourly-4", Date.parse("2025-12-13T07:00:00.000Z")),

57+

createDailyCronJob("daily-overflow", Date.parse("2025-12-13T09:00:00.000Z")),

58+

],

59+

});

60+61+

const state = createCronServiceState({

62+

cronEnabled: true,

63+

storePath: store.storePath,

64+

log: noopLogger,

65+

nowMs: () => startNow,

66+

enqueueSystemEvent: vi.fn(),

67+

requestHeartbeat: vi.fn(),

68+

runIsolatedAgentJob: vi.fn(async () => ({ status: "ok" as const })),

69+

});

70+71+

await start(state);

72+73+

const deferred = state.store?.jobs.find((job) => job.id === "daily-overflow");

74+75+

expect(deferred?.state.nextRunAtMs).toBe(startNow + 5_000);

76+

expect(deferred?.state.nextRunAtMs).not.toBe(tomorrowNaturalSlot);

77+78+

state.stopped = true;

79+

await store.cleanup();

80+

});

81+82+

it("still repairs a stale future cron slot on start() when no jobs were deferred", async () => {

83+

const store = await makeStorePath();

84+

const startNow = Date.parse("2025-12-13T17:00:00.000Z");

85+

const staleFutureSlot = Date.parse("2025-12-13T18:00:00.000Z");

86+

const naturalSlot = Date.parse("2025-12-14T09:00:00.000Z");

87+88+

await saveCronStore(store.storePath, {

89+

version: 1,

90+

jobs: [createDailyCronJob("daily-stale-future", staleFutureSlot)],

91+

});

92+93+

const state = createCronServiceState({

94+

cronEnabled: true,

95+

storePath: store.storePath,

96+

log: noopLogger,

97+

nowMs: () => startNow,

98+

enqueueSystemEvent: vi.fn(),

99+

requestHeartbeat: vi.fn(),

100+

runIsolatedAgentJob: vi.fn(async () => ({ status: "ok" as const })),

101+

});

102+103+

await start(state);

104+105+

const repaired = state.store?.jobs.find((job) => job.id === "daily-stale-future");

106+107+

expect(repaired?.state.nextRunAtMs).toBe(naturalSlot);

108+

expect(repaired?.state.nextRunAtMs).not.toBe(staleFutureSlot);

109+110+

state.stopped = true;

111+

await store.cleanup();

112+

});

113+

});