#436 BUG: durable_cron never fires - last_run variable not persisted before first sleep
Description
Edit
## Problem
The durable_cron tool never actually spawns child workflows. It keeps waking up, recalculating next_run, and going back to sleep.
## Root Cause
In engine/tools/durable_cron.py:
1. last_run_time is retrieved with ctx.get_variable(..., default=NOW)
2. If variable doesn't exist (first run), defaults to NOW
3. next_run = croniter(cron_expression, last_run_time).get_next() = next minute
4. Since now < next_run, sleep_duration > 0, workflow sleeps
5. On wake, the variable STILL doesn't exist (only saved after spawn)
6. Defaults to NOW again, repeats forever
## Expected Behavior
- calc_next checkpoint should return cached next_run time on wake
- OR last_run should be saved BEFORE first sleep
## Actual Behavior
- calc_next step re-executes each wake (checkpoint not honored)
- last_run never saved (spawn never reached)
- Workflow loops forever in sleep-wake cycle
## Steps to Reproduce
1. Submit a durable_cron workflow
2. Check logs - see 'Sleeping for Xs' messages every minute
3. Never see 'Time to run! Spawning target task...' message
## Affected Workflows
- farshid_health_scheduler (57d1cff8-4407-4a8e-8e1a-6acb6a44c64b)
- Any durable_cron workflow
## Additional Issues
- No customer visibility (task_count=0, cryptic step names)
- workflow_schedules.last_run_at never updated
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...