#11813: fix(cron): ensure 'at' schedule type correctly registers nextWakeAtMs during update
stale
Cluster:
Cron Enhancements and Fixes
Fixes #11795. This PR simplifies `computeJobNextRunAtMs` for 'at' schedules by delegating to `computeNextRunAtMs`, which correctly handles past/future checks. This ensures that when a job is updated to an 'at' schedule, the scheduler correctly registers the next wake time.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes cron job updates for one-shot `at` schedules by simplifying `computeJobNextRunAtMs` to delegate to `computeNextRunAtMs`, which applies the past/future cutoff consistently (and still supports legacy `atMs`). It also adds a Vitest regression test reproducing issue #11795 by updating an existing cron job to an `at` schedule in the past and then in the future, asserting `nextWakeAtMs` behavior matches expectations.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge after fixing minor test hygiene issues.
- The core logic change is small and delegates to the existing schedule computation, which already contains the legacy `atMs` handling and the past/future cutoff needed for the reported bug. The main remaining issues are in the new regression test (unused variables and loose typing via `as any`), which could fail CI or reduce test robustness.
- src/cron/repro_11795.test.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#8811: fix(cron): handle atMs fallback for kind=at jobs
by hlibr · 2026-02-04
88.9%
#12303: fix(cron): correct nextRunAtMs calculation and prevent timer stall
by colddonkey · 2026-02-09
88.0%
#5428: fix(Cron): prevent one-shot loop on skip
by imshrishk · 2026-01-31
87.9%
#12443: fix(cron): don't advance past-due jobs that haven't been executed
by rummangeminicode · 2026-02-09
85.2%
#9088: fix(cron): ensure nextRunAtMs is computed when enabled is undefined...
by divol89 · 2026-02-04
84.8%
#14667: fix: preserve missed cron runs when updating job schedule
by WalterSumbon · 2026-02-12
84.4%
#5624: add support_human_readable_time_format in cron
by simran122 · 2026-01-31
83.4%
#12747: fix: catch up missed cron-expression job runs on restart
by obin94-commits · 2026-02-09
83.0%
#10120: fix(cron): ensure next run is strictly in the future (#10035)
by zenchantlive · 2026-02-06
82.7%
#9060: Fix: Preserve scheduled cron jobs after gateway restart
by vishaltandale00 · 2026-02-04
82.5%