Skip to content

routines: set retryAt when holding a queued interval run outside its window - #474

Merged
SiddDevZ merged 2 commits into
DuskBotAI:devfrom
samyyy2311:fix-held-interval-retry-at
Dec 3, 2026
Merged

SiddDevZ merged 2 commits into
DuskBotAI:devfrom
samyyy2311:fix-held-interval-retry-at

Conversation

@samyyy2311

@samyyy2311 samyyy2311 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What and why

When a scheduled interval routine with a weekdays or window restriction holds a queued run because the current time is outside its allowed window (or before the next aligned occurrence), RoutineManager.tick() checks nextOccurrence(definition.schedule, now) for null but never sets run.retryAt. Because startsLater() treats retryAt === undefined as due immediately, hasActiveRuns(), wakeHold(), and schedulerDueOf() treat the held run as active now, keeping Cloud homes and desktops awake and re-arming the due timer every 10 seconds until the next allowed occurrence.

This extracts intervalDispatch() into server/routine-schedules.ts, sets run.retryAt while holding the run (saving and emitting when scheduledFor or retryAt changes), and clears that parked retryAt in RoutineManager.update() if the routine's schedule is edited (while leaving retried / busy-wait attention runs untouched) so a widened schedule dispatches promptly.

How it was checked

  • corepack pnpm vitest run scripts/testing/file-size-ratchet.test.ts server/routines.test.ts server/routine-due.test.ts server/routine-recovery.test.ts: 4 test files, 293 tests passed (including assertions for retryAt, hasActiveRuns(), wakeHold(), schedulerDueOf(), and widening an edited schedule).

  • corepack pnpm typecheck: passed.

  • corepack pnpm lint: passed (0 warnings, 0 errors).

  • pnpm typecheck, pnpm lint and pnpm test pass (typecheck, lint, and the 4 Vitest suites above passed; full pnpm test not run locally)

  • New behaviour has a test

  • No secrets, personal data or local paths in the diff or screenshots

…window

When a scheduled interval run with a window or weekday restriction is held because the current time is outside its allowed window or before the next aligned occurrence, set run.retryAt to the next allowed occurrence so hasActiveRuns(), wakeHold(), and schedulerDueOf() do not keep Cloud or desktop awake or spin the scheduler every 10 seconds. Clear that parked retryAt if the routine's schedule is edited so a wider window dispatches promptly.
@SiddDevZ
SiddDevZ merged commit b44c9e2 into DuskBotAI:dev Dec 3, 2026
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants