Skip to content

Cron job update occasionally produces incorrect nextRunAtMs (72-hour offset) #10548

@ayush-patel

Description

@ayush-patel

Bug Description

When updating cron jobs with timezone changes, the nextRunAtMs calculation occasionally produces incorrect values. Observed a 72-hour (3-day) offset where Friday was skipped to Monday.

Steps to Reproduce

  1. Create a cron job with expression 0 8 * * 1-5 and tz: America/Los_Angeles
  2. At ~10:35 PM CST Thursday, update multiple jobs in parallel (via tool calls) to change timezone to America/Chicago
  3. Observe that one job gets incorrect nextRunAtMs (Monday instead of Friday)

Expected Behavior

Job with 0 8 * * 1-5 updated at 10:35 PM Thursday (CST) should schedule next run for Friday 8 AM CST.

Actual Behavior

  • 2 of 3 jobs updated simultaneously got correct values
  • 1 job (day-of-week constrained 1-5) got Monday Feb 9 instead of Friday Feb 6

Evidence

Direct testing with croner library returns correct result:

const { Cron } = require('croner');
const now = new Date('2026-02-06T04:35:22.877Z'); // 10:35 PM CST Thursday
const cron = new Cron('0 8 * * 1-5', { timezone: 'America/Chicago' });
cron.nextRun(now); // Returns Friday Feb 6, 8 AM ✅

But stored nextRunAtMs was 1770645600000 (Monday Feb 9, 8 AM).

Environment

  • OpenClaw version: 2026.2.3-1
  • OS: macOS Darwin 24.6.0 (arm64)
  • Node: v22.22.0

Hypothesis

Possible race condition in parallel job updates, or state corruption during persist. The croner library is correct; issue is between library call and persisting result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions