openclaw - ✅(Solved) Fix [Bug]: Cron bug TypeError: Cannot read properties of undefined (reading 'runningAtMs') [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#65193Fetched 2026-04-12 13:25:08
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2referenced ×1

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。

Root Cause

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。

Fix Action

Fixed

PR fix notes

PR #65206: fix: preserve cron persisted runtime state on load

Description (problem / solution / changelog)

Summary

  • preserve persisted job.state when cron jobs are normalized during store load
  • keep legacy runtime fields like runningAtMs and nextRunAtMs available for startup catch-up
  • add a regression test covering persisted runtime state round-tripping through ensureLoaded()

Testing

  • ./node_modules/.bin/vitest run src/cron/service/store.test.ts src/cron/service.restart-catchup.test.ts

Fixes #65193

Changed files

  • src/cron/normalize.ts (modified, +69/-0)
  • src/cron/service/store.test.ts (modified, +38/-0)

PR #65232: fix(cron): guard job.state before accessing in planStartupCatchup

Description (problem / solution / changelog)

Summary\nFixes TypeError when cron service starts up and accesses job.state.runningAtMs on jobs whose state is undefined.\n\n## Root Cause\nJobs loaded from the persistent store may be missing the state field if they were created via CronJobCreate (where state is optional). When planStartupCatchup runs after gateway restart, it accesses job.state.nextRunAtMs (in sort comparator) and job.state.runningAtMs (in loop) without guarding against undefined state, causing:\n\nTypeError: Cannot read properties of undefined (reading 'runningAtMs')\n\n\n## Changes\n- Add job.state guard in planStartupCatchup before accessing job.state in the sort comparator\n- Add job.state guard before setting runningAtMs in the startupCandidates loop\n\n## Testing\n- Fixes v2026.4.9 regression where cron crashes on restart due to missing job state\n- No behavior change for jobs with properly initialized state\n\nCloses #65193

Changed files

  • src/cron/service/timer.ts (modified, +10/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。

Steps to reproduce

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。

Expected behavior

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。 3.29就,没问题 doker 4.10无法升级

Actual behavior

Cron 调度器 bug 定位:

Copy TypeError: Cannot read properties of undefined (reading 'runningAtMs') 错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。

实际可行方案:直接修改 jobs.json + 手动触发 gateway 重启(发信号),绕过 CLI:
WebSocket auth握手后 gateway 无响应了。让我直接通过 HTTP API 检查 cron 状态:

OpenClaw version

2026.4.9

Operating system

Debina13

Install method

Docker

Model

minamx.2.7

Provider / routing chain

Openclaw-gateway->mainmax->feishu

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

Modify the jobs.json file and manually trigger a gateway restart to bypass the CLI issue.

Guidance

  • Identify the jobs.json file and manually update it to ensure all job objects have the required state property.
  • Manually trigger a gateway restart by sending a signal to bypass the CLI issue.
  • Use the HTTP API to check the cron status after the WebSocket authentication handshake.
  • Verify that the cron.start() method is called after the gateway restart to ensure the cron scheduler is properly initialized.

Example

No code snippet is provided as the issue does not contain sufficient information to generate a specific example.

Notes

The provided solution is a workaround and may not be a permanent fix. The root cause of the issue appears to be a bug in the OpenClaw 2026.4.9 cron subsystem.

Recommendation

Apply the workaround by modifying the jobs.json file and manually triggering a gateway restart, as this is the most straightforward solution to bypass the CLI issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Cron 调度器 bug 定位:

TypeError: Cannot read properties of undefined (reading 'runningAtMs')

错误发生在 cron.start() → runMissedJobs() → planStartupCatchup() 执行期间,job 对象在内存中被替换成了缺少 state 的版本。这是 OpenClaw 2026.4.9 的 cron 子系统 bug。

CLI 无法调用的原因: openclaw cron add/list 通过 WebSocket 连接 gateway RPC 调用 cron 方法,gateway 每次重启后 cron 都会崩溃重启,WebSocket 握手就卡住了,导致 CLI 无响应。 3.29就,没问题 doker 4.10无法升级

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING