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

推荐订阅源

Google DeepMind News
Google DeepMind News
I
InfoQ
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
GbyAI
GbyAI
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
美团技术团队
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
M
MIT News - Artificial intelligence
D
Docker
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 叶小钗

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): record interrupted startup runs · openclaw/ope...
vincentkoc · 2026-04-25 · via Recent Commits to openclaw:main

@@ -3,6 +3,7 @@ import path from "node:path";

33

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

44

import { CronService } from "./service.js";

55

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

6+

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

67

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

78

import { runMissedJobs } from "./service/timer.js";

89

@@ -21,6 +22,7 @@ describe("CronService restart catch-up", () => {

2122

storePath: string;

2223

enqueueSystemEvent: ReturnType<typeof vi.fn>;

2324

requestHeartbeatNow: ReturnType<typeof vi.fn>;

25+

onEvent?: ReturnType<typeof vi.fn>;

2426

}) {

2527

return new CronService({

2628

storePath: params.storePath,

@@ -29,6 +31,7 @@ describe("CronService restart catch-up", () => {

2931

enqueueSystemEvent: params.enqueueSystemEvent as never,

3032

requestHeartbeatNow: params.requestHeartbeatNow as never,

3133

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

34+

onEvent: params.onEvent as ((evt: CronEvent) => void) | undefined,

3235

});

3336

}

3437

@@ -53,23 +56,26 @@ describe("CronService restart catch-up", () => {

5356

cron: CronService;

5457

enqueueSystemEvent: ReturnType<typeof vi.fn>;

5558

requestHeartbeatNow: ReturnType<typeof vi.fn>;

59+

onEvent: ReturnType<typeof vi.fn>;

5660

}) => Promise<void>,

5761

) {

5862

const store = await makeStorePath();

5963

const enqueueSystemEvent = vi.fn();

6064

const requestHeartbeatNow = vi.fn();

65+

const onEvent = vi.fn();

61666267

await writeStoreJobs(store.storePath, jobs);

63686469

const cron = createRestartCronService({

6570

storePath: store.storePath,

6671

enqueueSystemEvent,

6772

requestHeartbeatNow,

73+

onEvent,

6874

});

69757076

try {

7177

await cron.start();

72-

await run({ cron, enqueueSystemEvent, requestHeartbeatNow });

78+

await run({ cron, enqueueSystemEvent, requestHeartbeatNow, onEvent });

7379

} finally {

7480

cron.stop();

7581

await store.cleanup();

@@ -115,7 +121,7 @@ describe("CronService restart catch-up", () => {

115121

);

116122

});

117123118-

it("replays interrupted recurring job on first restart (#60495)", async () => {

124+

it("marks interrupted recurring jobs failed instead of replaying them on startup", async () => {

119125

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

120126

const staleRunningAt = Date.parse("2025-12-13T16:30:00.000Z");

121127

@@ -137,23 +143,32 @@ describe("CronService restart catch-up", () => {

137143

},

138144

},

139145

],

140-

async ({ cron, enqueueSystemEvent, requestHeartbeatNow }) => {

146+

async ({ cron, enqueueSystemEvent, requestHeartbeatNow, onEvent }) => {

141147

expect(noopLogger.warn).toHaveBeenCalledWith(

142148

expect.objectContaining({ jobId: "restart-stale-running" }),

143-

"cron: clearing stale running marker on startup",

149+

"cron: marking interrupted running job failed on startup",

144150

);

145151146-

expect(enqueueSystemEvent).toHaveBeenCalledWith(

147-

"resume stale marker",

148-

expect.objectContaining({ agentId: undefined }),

149-

);

150-

expect(requestHeartbeatNow).toHaveBeenCalled();

152+

expect(enqueueSystemEvent).not.toHaveBeenCalled();

153+

expect(requestHeartbeatNow).not.toHaveBeenCalled();

151154152155

const listedJobs = await cron.list({ includeDisabled: true });

153156

const updated = listedJobs.find((job) => job.id === "restart-stale-running");

154157

expect(updated?.state.runningAtMs).toBeUndefined();

155-

expect(updated?.state.lastStatus).toBe("ok");

156-

expect(updated?.state.lastRunAtMs).toBe(Date.parse("2025-12-13T17:00:00.000Z"));

158+

expect(updated?.state.lastStatus).toBe("error");

159+

expect(updated?.state.lastRunStatus).toBe("error");

160+

expect(updated?.state.lastRunAtMs).toBe(staleRunningAt);

161+

expect(updated?.state.lastError).toBe("cron: job interrupted by gateway restart");

162+

expect(updated?.state.nextRunAtMs).toBeGreaterThan(Date.parse("2025-12-13T17:00:00.000Z"));

163+

expect(onEvent).toHaveBeenCalledWith(

164+

expect.objectContaining({

165+

action: "finished",

166+

jobId: "restart-stale-running",

167+

status: "error",

168+

error: "cron: job interrupted by gateway restart",

169+

runAtMs: staleRunningAt,

170+

}),

171+

);

157172

},

158173

);

159174

});

@@ -194,7 +209,7 @@ describe("CronService restart catch-up", () => {

194209

);

195210

});

196211197-

it("does not replay interrupted one-shot jobs on startup", async () => {

212+

it("marks interrupted one-shot jobs failed and disabled on startup", async () => {

198213

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

199214

const staleRunningAt = Date.parse("2025-12-13T16:30:00.000Z");

200215

@@ -216,13 +231,28 @@ describe("CronService restart catch-up", () => {

216231

},

217232

},

218233

],

219-

async ({ cron, enqueueSystemEvent, requestHeartbeatNow }) => {

234+

async ({ cron, enqueueSystemEvent, requestHeartbeatNow, onEvent }) => {

220235

expect(enqueueSystemEvent).not.toHaveBeenCalled();

221236

expect(requestHeartbeatNow).not.toHaveBeenCalled();

222237223238

const listedJobs = await cron.list({ includeDisabled: true });

224239

const updated = listedJobs.find((job) => job.id === "restart-stale-one-shot");

240+

expect(updated?.enabled).toBe(false);

225241

expect(updated?.state.runningAtMs).toBeUndefined();

242+

expect(updated?.state.lastStatus).toBe("error");

243+

expect(updated?.state.lastRunStatus).toBe("error");

244+

expect(updated?.state.lastRunAtMs).toBe(staleRunningAt);

245+

expect(updated?.state.nextRunAtMs).toBeUndefined();

246+

expect(updated?.state.lastError).toBe("cron: job interrupted by gateway restart");

247+

expect(onEvent).toHaveBeenCalledWith(

248+

expect.objectContaining({

249+

action: "finished",

250+

jobId: "restart-stale-one-shot",

251+

status: "error",

252+

error: "cron: job interrupted by gateway restart",

253+

runAtMs: staleRunningAt,

254+

}),

255+

);

226256

},

227257

);

228258

});