fix(heartbeat): emit valid + even cron expressions on Linux/WSL#2
Open
oratis wants to merge 1 commit into
Open
fix(heartbeat): emit valid + even cron expressions on Linux/WSL#2oratis wants to merge 1 commit into
oratis wants to merge 1 commit into
Conversation
`secondsToCronApprox` produced cron lines that cron either rejects outright (minute >59 / hour >23) or silently runs unevenly (`*/5` on hours fires at 00,05,10,15,20 then resets, leaving a 4h gap). macOS users are unaffected — launchd uses `StartInterval` (seconds) and never hits this path. Snap to safe field divisors and surface the rounding in the installer's printed instructions so users see what their `--every` actually became: --every 5h → 0 */4 * * * (was: 0 */5 * * *, invalid wrap-around) --every 7h → 0 */6 * * * (was: 0 */7 * * *, invalid wrap-around) --every 90m → 0 * * * * (was: */90 * * * *, rejected by cron) --every 25h → 0 0 * * * (was: 0 */25 * * *, rejected by cron) --every 8d → 0 0 * * 0 (weekly) Pure internal change to `src/heartbeat/install.ts`. No public API change, no new deps. Closes #1 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
What
secondsToCronApproxinsrc/heartbeat/install.tsis the Linux/WSL fallback forlisa heartbeat install --every <N>(macOS uses launchdStartIntervaland never hits this path). The previous implementation produced cron lines that were either rejected by cron (*/90 * * * *,0 */25 * * *) or run on an uneven schedule (0 */5 * * *fires at 00 05 10 15 20 then jumps back to 00 — only 4h between the last run and the next).Change
Snap to safe field divisors:
--every 5h0 */5 * * *(invalid wrap-around)0 */4 * * *--every 7h0 */7 * * *(invalid wrap-around)0 */6 * * *--every 90m*/90 * * * *(rejected by cron)0 * * * *--every 25h0 */25 * * *(rejected by cron)0 0 * * *(daily)--every 8d0 0 * * 0(weekly)When a snap occurs, the installer's printed instructions now include a one-line note like:
Verification
Ran a behavior table over 15 input values — all outputs are now syntactically valid cron and produce even intervals across day boundaries. Output table is in the issue and the commit message.
Scope
src/heartbeat/install.tssecondsToCronApprox) and its one caller (Linux branch ofinstallHeartbeat)npm run typecheckclean,npm run buildclean🤖 Generated with Claude Code