You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lastExecution (which is returned by lastDate()) is not about the last time we ran the onTick function, but about the last time we checked if we should run it (which will differ only when the time between executions is > ~ 24.85 days).
Expected Behavior
lastExecution should be updated only when we run the onTick function.
Actual Behavior
lastExecution is updated when we check if we should run the onTick function.
it('should give the correct last execution date for monthly crons',()=>{constcallback=jest.fn();constclock=sinon.useFakeTimers();// At 00:00 on day-of-month 1.constjob=newCronJob('0 0 0 1 * *',callback);job.start();// tick 25 days (MAX_TIMEOUT == 2147483647 ms == ~ 24,85 days)clock.tick(1000*60*60*24*25);expect(callback).toHaveBeenCalledTimes(0);expect(job.lastDate()?.getTime()).toBeUndefined();job.stop();clock.restore();});
result
observations
callback was never called, but we still have a lastExecution (which equals the MAX_DELAY value).
Context
N/A
Your Environment
cron version: v3.0.0
NodeJS version: v18.17.1
Operating System and version: Ubuntu 22.04.3 (jammy)
TypeScript version (if applicable):
Link to your project (if applicable):
The text was updated successfully, but these errors were encountered:
sheerlox
changed the title
lastDate() value for cron intervals > ~ 24.85 days is sometimes wrong
lastDate() value for cron intervals > 25 days is sometimes wrong
Oct 2, 2023
Description
lastExecution
(which is returned bylastDate()
) is not about the last time we ran theonTick
function, but about the last time we checked if we should run it (which will differ only when the time between executions is > ~ 24.85 days).Expected Behavior
lastExecution
should be updated only when we run theonTick
function.Actual Behavior
lastExecution
is updated when we check if we should run theonTick
function.Possible Fix
Move
lastExecution
update from line 227 to line 239.Steps to Reproduce
test case
result
observations
callback
was never called, but we still have alastExecution
(which equals theMAX_DELAY
value).Context
N/A
Your Environment
cron
version:v3.0.0
v18.17.1
Ubuntu 22.04.3 (jammy)
The text was updated successfully, but these errors were encountered: