Skip to content

fix(workflows): align nextFire interval calculation with dispatcher clock (#2788) - #2799

Open
isihussain wants to merge 1 commit into
danielmiessler:mainfrom
isihussain:fix/workflow-next-interval-clock
Open

isihussain wants to merge 1 commit into
danielmiessler:mainfrom
isihussain:fix/workflow-next-interval-clock

Conversation

@isihussain

Copy link
Copy Markdown

Summary

Fixes #2788.

For an interval trigger, workflow next and the dispatcher previously computed different fire times:

  • workflow next computed lastStart + period (
    extFire, interval case).
  • The dispatcher finds due occurrences with occurrencesBetween / occurrencesIn, placing interval occurrences at multiples of the period counted from the Unix epoch.

This caused workflow next to diverge whenever a run started with latency or off-grid (e.g. reporting 23:45Z when the dispatcher fires at 00:00Z).

Solution

  1. Updated
    extFire in LIFEOS/WORKFLOWS/engine/schedule.ts (interval case) to query occurrencesBetween for the next epoch-grid occurrence, aligning it directly with the dispatcher's clock.
  2. Added LIFEOS/WORKFLOWS/engine/schedule.next.test.ts covering off-grid last runs, execution latency, and on-grid controls.

Signed-off-by: isihussain isihussain@users.noreply.github.com

…lock (danielmiessler#2788)

For interval triggers, nextFire previously computed lastStart + period,
drifting whenever runs started off-grid or with tick latency. The dispatcher
fires on multiples of the period counted from the Unix epoch via
occurrencesIn/occurrencesBetween.

Update nextFire interval case to query occurrencesBetween for the next
epoch-grid occurrence, ensuring workflow next and the dispatcher agree.
Add schedule.next.test.ts covering off-grid and tick latency scenarios.

Closes danielmiessler#2788

Signed-off-by: isihussain <isihussain@users.noreply.github.com>
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.

workflow next and the dispatcher disagree on when an interval trigger fires

1 participant