Skip to content

fix: keep recurring tasks scheduled after failed runs - #27

Open
charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix-recurring-tasks-after-failure
Open

charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix-recurring-tasks-after-failure

Conversation

@charan-rathore

Copy link
Copy Markdown

Design question

Today a recurring (interval) scheduled task keeps repeating only after a successful run. If a run fails, it is not claimed again. I could not tell whether that is intended. This PR proposes the other behavior. If success-only repetition is what you want, please close this with a word and I will not mind.

What this changes

  • A failed interval task keeps its failed status and history, and becomes claimable again after the full interval. There is no immediate retry.
  • The claim query now selects failed interval tasks whose next run is due.
  • One-shot tasks, paused or cancelled tasks, removing the schedule, and editing the interval all stay guarded, including when a failure arrives late.
  • The event copy now says the task repeats after each run, not after each successful run.

Tradeoff

A failed recurring task now keeps making provider requests at the same interval, where before it stopped. That is the cost to weigh against a task that silently stops after one bad run.

Tests

Added a test on the real SQLite store covering the due time, exclusive claim and history across two connections. It fails on the base commit. There are six scenarios in total, including the one-shot, the pause or cancel with a late failure, and removing or editing the schedule.

Results below are from the person who prepared the change; I did not rerun them. Full suite: 34 files, 162 tests pass. Format, lint, typecheck and production build pass (the build prints a chunk size warning that was already there). No dependency changes.

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