Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agenda job computes new nextRunAt to be current nextRunAt #858

Closed
ukcrpb6 opened this issue Sep 18, 2019 · 1 comment
Closed

Agenda job computes new nextRunAt to be current nextRunAt #858

ukcrpb6 opened this issue Sep 18, 2019 · 1 comment

Comments

@ukcrpb6
Copy link

@ukcrpb6 ukcrpb6 commented Sep 18, 2019

Expected Behaviour

nextRunAt should not be the current nextRunAt but the next interval ahead of the current nextRunAt

Current Behaviour

Agenda job computes new nextRunAt to be current nextRunAt.

for example,

Screenshot 2019-09-18 at 16 41 39

In the above the new lastRunAt for a job running at 2019-09-16T15:30:00Z is computed to be 2019-09-16T15:29:59.999Z leading to the computation of nextRunAt to be 2019-09-16T15:30:00Z which doesn't trigger the check here

if (nextDate.valueOf() === lastRun.valueOf()) {
        // Handle cronTime giving back the same date for the next run time
        nextDate = cronTime._getNextDateFrom(dateForTimezone(new Date(lastRun.valueOf() + 1000)));
}

thus causing the job to run twice.

Possible Solution

One possible solution is that when the run task computes the lastRunAt here:

self.attrs.lastRunAt = new Date();

It checks that that the computed values is greater than the job's nextRunAt (currently unmodified so should be the expected run time for the currently executing job.

@koresar

This comment has been minimized.

Copy link
Contributor

@koresar koresar commented Dec 16, 2019

The fix is merged. Expected to be published with the next release.

@koresar koresar closed this Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.