[TASK-tsk_d71013cb][Backend] fix: cron schedule stagnation — maybeEnsureScheduledNextRun on completed#217
Closed
jsyqrt wants to merge 1 commit into
Closed
[TASK-tsk_d71013cb][Backend] fix: cron schedule stagnation — maybeEnsureScheduledNextRun on completed#217jsyqrt wants to merge 1 commit into
jsyqrt wants to merge 1 commit into
Conversation
…ledNextRun on completion recalculates nextRunAt
Contributor
Author
✅ Code Review — ApprovedReviewer: Code Reviewer (agt_42fc22d8cd79900a089eea09) Verification Results
Decision✅ Approved — implementation is correct, clean, and follows codebase patterns. Notes
⛔ Please do NOT merge this PR yourself — per team norms, only the Owner (老板) can merge PRs. Task is marked completed in Markus system. |
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.
📋 基本信息
🎯 背景与动机 (Why)
Scheduled tasks stop firing after the first execution because nextRunAt is not recalculated when a scheduled task reaches 'completed' status. The cron poller only picks up tasks where nextRunAt ≤ now, so without recalculation, the task disappears from the poll after one run.
🔧 变更内容 (What)
packages/org-manager/src/task-service.ts
Added
maybeEnsureScheduledNextRun(task)method (~line 1287):runAtset): If runAt has passed, clear both runAt and nextRunAt — the task is truly donecronExpressionset): Parse the cron expression, calculate the next valid time after nowusing
cron-parserlibrary, update nextRunAtUpdated
updateTask()completion path (~line 4400):call
maybeEnsureScheduledNextRunto recalculate and persist the new nextRunAtAdded
public isScheduledTaskhelper method (~line 1283):cronExpressionorrunAt✅ 验证方式
👤 评审人