Skip to content

fix: claim exhausted RRULE schedules and disable them instead of skipping#5634

Merged
siddseethepalli merged 1 commit into
mainfrom
fix/exhausted-rrule-claim-5516
Feb 19, 2026
Merged

fix: claim exhausted RRULE schedules and disable them instead of skipping#5634
siddseethepalli merged 1 commit into
mainfrom
fix/exhausted-rrule-claim-5516

Conversation

@siddseethepalli
Copy link
Copy Markdown
Contributor

@siddseethepalli siddseethepalli commented Feb 19, 2026

Address reviewer feedback on PR #5516.

When a finite RRULE schedule (e.g. COUNT=1) is exhausted, computeNextRunAtEngine throws because there are no future occurrences. Previously, the catch block in claimDueSchedules would skip the job entirely, meaning the current due run was never claimed/executed and the row remained perpetually due.

Now, exhausted schedules are still claimed (so the due run executes) but are disabled (enabled=false, nextRunAt=0) so they don't fire again.

Adds a test covering the exhausted RRULE claim + disable behavior.


Open with Devin

…ping

Co-Authored-By: Claude <noreply@anthropic.com>
@siddseethepalli siddseethepalli self-assigned this Feb 19, 2026
@siddseethepalli siddseethepalli merged commit 2b7e85f into main Feb 19, 2026
@siddseethepalli siddseethepalli deleted the fix/exhausted-rrule-claim-5516 branch February 19, 2026 23:20
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbe8c31775

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 219 to +223
} catch {
// Expression has no future runs — skip
continue;
// Finite schedule with no future runs — still claim the current due
// run but disable the schedule so it doesn't fire again.
newNextRunAt = null;
exhausted = true;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Narrow exhaustion fallback to no-future-run errors

This catch now treats every computeNextRunAtEngine failure as an exhausted schedule and disables the row, but computeNextRunAtEngine also throws for non-exhaustion problems (for example invalid RRULE lines or unsupported syntax in recurrence-engine.ts). In those cases we would silently mark the job disabled and still run its payload once, which hides data issues and permanently turns schedules off instead of surfacing the real error path. Please only apply the disable-and-claim behavior for explicit "no upcoming runs" failures and rethrow other exceptions.

Useful? React with 👍 / 👎.


test('claims exhausted RRULE schedule and disables it', () => {
// COUNT=1 means only one occurrence — the DTSTART itself
const rrule = 'DTSTART:20250101T000000Z\nRRULE:FREQ=DAILY;COUNT=1';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make exhausted RRULE test independent of wall-clock date

This test hardcodes DTSTART:20250101... for a COUNT=1 enabled RRULE, but createSchedule computes nextRunAt immediately and throws once that date is in the past, so the test stops before exercising claimDueSchedules. As time advances, this regression test becomes invalid/flaky and no longer verifies the intended behavior; use a future date relative to Date.now() (or freeze time) before forcing next_run_at to past.

Useful? React with 👍 / 👎.

@siddseethepalli
Copy link
Copy Markdown
Contributor Author

Addressed in #6278

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.

1 participant