Repository navigation
fix(taskhelper): stop the cron runner when no next execution date exists - #382
Merged
Merged
Conversation
3 tasks done
Member
|
Hi @ToniAdreal thank you for your contribution ! Can you solve the conflict please ? |
If Schedule.Next returns the zero time after a firing (e.g. a leap-day schedule whose next match is more than five years away because 2100 is not a leap year), arming a timer with a negative duration executes the task in a busy loop. Log an error and stop the runner instead. Adds TestCron_StopsWhenNoNextExecutionDate, which builds the runner directly with a never-matching schedule (NewCron rejects it) and asserts the task never executes, the runner stops promptly, and an error is logged. Assisted-by: Muse Spark:1.3 Signed-off-by: ToniAdreal <184365500+ToniAdreal@users.noreply.github.com>
ToniAdreal
force-pushed
the
toni-377-followup
branch
from
November 12, 2026 09:38
0722521 to
617b224
Compare
Nexucis
approved these changes
Nov 12, 2026
Nexucis
left a comment
Member
There was a problem hiding this comment.
awesome ! Thank you @ToniAdreal
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.
Follow-up to #377 (and #4732). The creation-time check in
NewCronrejects schedules that never match any date, butSchedule.Nextcan still return the zero time after a firing: it only searches five years ahead, so a leap-day schedule such as0 0 29 2 *passes the creation check yet has no match within five years after the2096-02-29firing (the next match is2104-02-29, an 8-year gap because 2100 is not a leap year). Arming a timer with the resulting negative duration would execute the task in a busy loop.This adds a belt-and-braces guard in
cron(): ifnext.IsZero(), log an error and stop the runner instead of arming the timer. The guard is checked at the top of the loop, so it covers both the initialNextand the one computed after each execution.Test:
TestCron_StopsWhenNoNextExecutionDatebuilds the runner directly with a never-matching schedule (NewCronrejects it) and asserts the task never executes, the runner stops promptly, and an error is logged. Verified locally: the test passes with the guard and fails without it (the runner never stops).