[Bug]: `interval`-triggered schedules never fire from their timer chain — cron triggers on the same install fire on time
Describe the Bug
Schedules created with an interval trigger stop firing — their timer never fires again, so the task silently stops running, even while the app is open for many hours. cron-triggered schedules on the same install keep firing exactly on time.
The user-visible symptom is "the scheduled task missed a run and never runs again", but the data shows it is not about missing a window: an interval schedule can be armed and still produce zero fires over a 15-hour uptime.
Evidence
Two schedules registered on the same installation, same period, same app sessions:
| Trigger | Observed fires |
|---|---|
cron 0 3 * * * (trash.purge, catch-up after-startup) |
Fired exactly at 03:00:00 on two consecutive days while the app was running |
interval ms: 3600000 (an agent.task, catch-up skip-missed) |
0 fires during 15 distinct online hours on the same day |
Raw rows from job for the cron schedule — note scheduled_at == created_at (no catch-up offset, i.e. a genuine timer fire):
created=2026-09-23 03:00:00 scheduled=2026-09-23 03:00:00 completed
created=2026-09-24 03:00:00 scheduled=2026-09-24 03:00:00 completedThe hourly interval schedule over the same period — every fire came from a manual / request-driven path, never from the interval chain. All five agent.task rows were preceded ~1s earlier by:
[WARN] SchedulerService "triggerNow only supported for cron schedules" id=schedule:<interval-id>which is the triggerJobScheduleNowById path, not a timer callback.
Detail of the dead window: the app logged 4 startups and 15 distinct online hours on that day; the hourly schedule was enabled = 1 throughout and produced zero job rows.
What I verified (and ruled out)
| Hypothesis | Verdict |
|---|---|
A job stuck in pending/running blocking later fires (the busy guard) |
Ruled out — all 44 rows in job are completed; zero non-terminal rows |
| The app wasn't running | Ruled out — 15 distinct online hours that day, taken from the app's own logs |
| Scheduler threw / logged errors | Ruled out — Schedule fire failed, interval-schedule callback error, armSchedule failed, Overdue detection failed all appear 0 times in the whole log set |
isAutonomySuspended stuck on (which would make interval callbacks return silently) |
Ruled out — every JobManager paused is matched by a JobManager pause hold released ~10s later (6 pauses / 33 releases, balanced; holds returns to 0) |
| Schedule was never armed | Ruled out — job_schedule.next_run is populated with a future timestamp for the interval rows, and getNextRun() only returns a value while a live entry exists in intervalHandles |
Where the code points
src/main/core/scheduler/SchedulerService.ts — scheduleInterval is a self-chaining setTimeout:
scheduleInterval(id, ms, callback) {
const fire = async () => {
const entry = this.intervalHandles.get(id);
if (!entry || entry.kind !== "interval") return;
entry.running = true;
try { await callback(); } catch (err) { logger.error("interval-schedule callback error", { id, error: err }); }
if (this.intervalHandles.get(id) !== entry) return;
const nextRunAt = Date.now() + ms;
const nextHandle = setTimeout(fire, ms);
nextHandle.unref?.(); // <-- the chain's only handle
entry.handle = nextHandle;
entry.nextRunAt = nextRunAt;
entry.running = false;
};
const nextRunAt = Date.now() + ms;
const handle = setTimeout(fire, ms);
handle.unref?.();
this.intervalHandles.set(id, { handle, kind: "interval", ms, callback, nextRunAt, running: false });
}Two things stand out against the cron path:
- The chain handle is created with
unref(). If anything in the main process lets the loop consider the timer droppable, the chain dies without a single log line — which matches the observed silence (no error,nextRunremains in the future, no fire). pause/resumeare documented no-ops for interval — the file's own comments say "those use chained setTimeout and cannot be paused — to 'pause' them, unregister and re-register when ready", and "resume is a no-op for interval/once schedules". The interval path is explicitly the least-supported trigger kind, and the one with no recovery affordance.
By contrast the cron path is backed by croner with its own nextRun(), and it demonstrably works on this machine.
One more observation that may be related
Twice, the startup recovery flow — the step that (re-)arms schedules — was skipped entirely because an auto-backup pause hold was active at exactly that moment:
[INFO] JobManager "Startup recovery deferred: JobManager is paused"
2026-09-22 14:34:22 (app started 14:33:18)
2026-09-27 09:54:58 (app started 09:53:53)In onAllReady():
if (this.isQuiesced) {
this.recoveryReplayPoint = { step: "reset" };
logger.info("Startup recovery deferred: JobManager is paused");
return; // full recovery (catch-up + arm + dispatch) is skipped
}Both deferrals landed ~64s after app start, i.e. inside the window between startup and the first AutoBackupService snapshot (reason: "backup: capture consistent snapshot"). This does not explain the interval-only failure by itself — cron schedules survived it — but a recovery path that can be silently deferred by a backup timer is worth hardening regardless (the file's own note that "a lost hold fails closed (paused until relaunch)" shows the authors were already aware of the failure mode).
Suggested Next Step
I could not isolate the final mechanism from the outside, so I am not claiming one. What would settle it is instrumentation the build does not currently emit:
- A debug/info log when
scheduleIntervalarms and whenfire()runs (right now a non-firing chain is completely silent). - Or: drop
unref()on the chain handle and re-test.
Environment
| Cherry Studio | v2.1.3 |
| OS | Windows 11 (10.0.26200), x64 |
| Install | packaged (not portable) |
| Schedule kinds | agent.task (interval), plus trash.purge (cron) as the control |
Source: CherryHQ/cherry-studio