Skip to content

[Bug] Cron job TimeoutOverflowWarning causes scheduler to skip runs indefinitely #11064

@doudian719

Description

@doudian719

Description

The Cron scheduler in OpenClaw 2026.2.3-1 has a critical bug where it calculates incorrect nextRunAtMs timestamps, causing TimeoutOverflowWarning in Node.js. This leads to the scheduler continuously skipping scheduled runs and pushing the next execution time further into the future.

Reproduction Steps

  1. Create a cron job with */15 * * * * schedule
  2. Let the job fail once (e.g., due to model fallback issues)
  3. Observe the scheduler behavior:
    • Expected: Next run at 15-minute intervals
    • Actual: Scheduler jumps to 30+ minutes in the future, then continues delaying

Error Logs

# Node.js warning
(node:3789) TimeoutOverflowWarning: 2592010000 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.

# Scheduler behavior observed
17:30 - Should run, skipped
17:45 - Expected, but scheduler shows next at 18:00
18:00 - Missed, pushed to 18:27
18:27 - Missed, pushed to 17:45 (the next day)

Impact

  • Severity: High
  • Affected: All cron-based scheduled tasks
  • Result: Tasks never execute automatically; manual intervention required
  • User Impact: Automation workflows completely broken

Environment

  • OpenClaw Version: 2026.2.3-1
  • Node.js: v25.5.0
  • OS: macOS (Darwin 25.2.0 arm64)
  • Schedule Config: */15 * * * * (cron expression)

Root Cause Analysis

The issue appears to be in the cron scheduling logic:

  1. After a task failure, the scheduler recalculates nextRunAtMs
  2. The calculation incorrectly produces a value ~30 days in the future: 2592010000 ms
  3. This exceeds Node.js's setTimeout maximum (~24.8 days)
  4. Result: TimeoutOverflowWarning and timer set to 1ms or invalid
  5. Scheduler enters a "protection mode" that continuously delays execution

Workarounds Tried

  1. ✅ Restarting Gateway - temporarily fixes until next failure
  2. ✅ Recreating job with every instead of cron - more stable but still delays
  3. ❌ Resetting job state - does not resolve underlying calculation bug

Suggested Fix

  1. Clamp the timeout value to Node.js's maximum before calling setTimeout
  2. Fix the cron next-run calculation to never exceed 24-hour lookahead
  3. Add bounds checking for all scheduler timestamp calculations

Related


Labels: bug, cron, scheduler
Priority: High

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