Repository navigation
routines: set retryAt when holding a queued interval run outside its window - #474
Merged
Merged
Conversation
…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.
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.
What and why
When a scheduled interval routine with a
weekdaysorwindowrestriction holds aqueuedrun because the current time is outside its allowed window (or before the next aligned occurrence),RoutineManager.tick()checksnextOccurrence(definition.schedule, now)fornullbut never setsrun.retryAt. BecausestartsLater()treatsretryAt === undefinedas due immediately,hasActiveRuns(),wakeHold(), andschedulerDueOf()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()intoserver/routine-schedules.ts, setsrun.retryAtwhile holding the run (saving and emitting whenscheduledFororretryAtchanges), and clears that parkedretryAtinRoutineManager.update()if the routine's schedule is edited (while leavingretried/ busy-waitattentionruns 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 forretryAt,hasActiveRuns(),wakeHold(),schedulerDueOf(), and widening an edited schedule).corepack pnpm typecheck: passed.corepack pnpm lint: passed (0 warnings, 0 errors).pnpm typecheck,pnpm lintandpnpm testpass (typecheck,lint, and the 4 Vitest suites above passed; fullpnpm testnot run locally)New behaviour has a test
No secrets, personal data or local paths in the diff or screenshots