-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Cron RPC queries (cron.list, cron.status) timeout when a job with wakeMode: "now" and sessionTarget: "main" is executing, because executeJob() holds the lock while awaiting runHeartbeatOnce().
Reproduction
- Create a cron job with
wakeMode: "now"andsessionTarget: "main" - Wait for the job to fire
- While the agent is processing the triggered turn, call
cron list - Query times out (10s default)
Root Cause
In dist/cron/service/timer.js lines 67-87:
// Inside executeJob(), which runs inside locked()
if (job.wakeMode === "now" && state.deps.runHeartbeatOnce) {
for (;;) {
heartbeatResult = await state.deps.runHeartbeatOnce({ reason });
if (...) break;
await delay(250); // Loops up to 2 minutes
}
}The locked() function in ops.js serializes ALL cron operations through state.op. Since executeJob() awaits the agent turn completion while holding the lock, any concurrent RPC query blocks.
Evidence from Logs
⇄ res ✓ cron.list 34021ms // Query took 34s (waited for lock)
⇄ res ✓ cron.status 15254ms // 15s wait
Suggested Fix
Options:
- Release lock before awaiting heartbeat - update job state after heartbeat completes
- Separate read/write locks - allow concurrent reads during job execution
- Move heartbeat await outside locked() - restructure to not hold lock during waits
Environment
- Clawdbot: 2026.1.24-3
- Node: v25.1.0
- macOS (arm64)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working