node-cron: Error: Something went wrong. cron reached maximum iterations

Time Zone: "" - Cron String: 0 0,30 * * * * - UTC offset: +00:00 - current Date: Mon Mar 16 2020 16:31:21 GMT+0000

cron@1.8.2 @types/cron@1.7.2

stacktrace:

at CronTime._getNextDateFrom (/usr/src/app/node_modules/cron/lib/cron.js:235:12)
at CronTime.sendAt (/usr/src/app/node_modules/cron/lib/cron.js:156:17)
at CronTime.getTimeout (/usr/src/app/node_modules/cron/lib/cron.js:175:29)
at CronJob.start (/usr/src/app/node_modules/cron/lib/cron.js:613:31)
at Timeout.callbackWrapper [as _onTimeout] (/usr/src/app/node_modules/cron/lib/cron.js:665:29)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)

index.ts:

import cron from "cron";

...

cron.job("0 0,30 * * * *", () => task(arg), undefined, true);

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 24 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I realized the error would show whenever my CPU utilization is too high (>9x%). That might cause some delay of code and affect something.

yes, it reappeared, though solved in 1.7 one year ago

cron@1.8.2

Error: Something went wrong. cron reached maximum iterations. 						
Please open an  issue (https://github.com/kelektiv/node-cron/issues/new) and provide the following string 	
					
Time Zone: "" - Cron String: 39 0,15,30,45 * * * * - UTC offset: +00:00 - current Date: Sat Mar 28 2020 13:30:45 GMT+0000     

at CronTime._getNextDateFrom (/app/node_modules/cron/lib/cron.js:235:12)     
at CronTime.sendAt (/app/node_modules/cron/lib/cron.js:156:17)     
at CronTime.getTimeout (/app/node_modules/cron/lib/cron.js:175:29)     at CronJob.start (/app/node_modules/cron/lib/cron.js:613:31)     
at Timeout.callbackWrapper [as _onTimeout] (/app/node_modules/cron/lib/cron.js:665:29)     
at listOnTimeout (internal/timers.js:531:17)     
at processTimers (internal/timers.js:475:7)

I pushed up a PR with some changes to allow a “soft warning”. Can you please test and report back?

@rusekr

Yea. I hear you re: still occurring.

This pr is to hopefully allow the developer to make the decision at to whether ms precision is necessary or not rather than throwing an exception.

I can take care of the warning showing at all later. Thanks for the docs.

As for the first point, re: default of false. I think you’re right. I’ll default it to true.

Great PR - it converts bug to feature, but if default for softTimeout is false - it is breaking change (with main commit caused this issue). And after upgrade to newer versions people must add this config in all cronjobs.

Meanwhile - even with softTimeout turned on this warning may occur in between server syncing time with ntp or changin from/to dst. Fot this js now have: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now and some examples https://developers.google.com/web/updates/2012/08/When-milliseconds-are-not-enough-performance-now Page on nodejs https://nodejs.org/api/perf_hooks.html#perf_hooks_performance_now

May be use this instead?

Thinking (but not tested) it related to this commit: https://github.com/kelektiv/node-cron/commit/e1b392f244025bbc833d648b33d01ee191640890 Can anyone test without it?

Reverted back to 1.7.2 for now.