fix(cron): bound tick cost and make every accepted schedule fire - #19
Merged
TheGreatAxios merged 1 commit intoSep 27, 2026
Conversation
Each expression is parsed once into allowed-value sets, capped at 256 characters and 64 clauses. The next-fire search skips non-matching days and hours, so it costs a few steps per day and covers eight years, long enough for Feb 29 across 2100. The ticker asks whether any minute after lastFiredAt (or createdAt) and at or before now matches, searching only the last window, so a Feb 29 schedule fires and an old anchor costs no more. POST rejects an expression that can never fire; the ticker stops such a row with invalid_expression instead of re-scanning it. `5/2` now steps to the field maximum. DOM/DOW OR semantics are unchanged. Closes CL-9447
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.
Summary
parseCronExpression), capped at 256 characters and 64 comma clauses. A 5,000-clause expression is rejected at parse time instead of costing minutes of CPU per tick.lastFiredAt(orcreatedAt) and at or before now matches, and only searches the last lookahead window. A Feb 29 schedule now fires, and an old anchor costs no more.POST /rejects an expression that can never fire (cronExpressionCanFire, now arithmetic). The ticker stops such a row withstoppedReason: "invalid_expression"and callsonScheduleStopped, instead of re-scanning it.n/stepwithout a range end steps to the field maximum (5/2→ 5,7,…,59).Stacked on #18.
Verification
bun run check, build,test:e2eagainst local Postgres, and the Node pack smoke pass. The new unit and e2e tests fail on #18 first. They cover5/2, the caps, never-firing expressions, Feb 29 (unit and e2e), OR semantics, and timing bounds.Closes CL-9447