cron 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [2.4.1](https://github.com/kelektiv/node-cron/compare/v2.4.0...v2.4.1) (2023-08-14)
2
+
3
+
4
+ ### 🐛 Bug Fixes
5
+
6
+ * replace loop timeout by max match date ([#686](https://github.com/kelektiv/node-cron/issues/686)) ([c685c63](https://github.com/kelektiv/node-cron/commit/c685c63a6d7fa86d6c8afca29b536b9da24e824b))
7
+
8
+
9
+ ### ⚙️ Continuous Integrations
10
+
11
+ * **renovate:** configure renovate ([#683](https://github.com/kelektiv/node-cron/issues/683)) ([9dbe962](https://github.com/kelektiv/node-cron/commit/9dbe962fad1c8b1b020441bce84ab91b1a7b4415))
12
+
1
13
  ## [2.4.0](https://github.com/kelektiv/node-cron/compare/v2.3.0...v2.4.0) (2023-07-24)
2
14
 
3
15
 
package/lib/time.js CHANGED
@@ -259,19 +259,23 @@ function CronTime(luxon) {
259
259
  throw new Error('ERROR: You specified an invalid date.');
260
260
  }
261
261
 
262
- // it shouldn't take more than 5 seconds to find the next execution time
263
- // being very generous with this. Throw error if it takes too long to find the next time to protect from
264
- // infinite loop.
265
- const timeout = Date.now() + 5000;
262
+ /**
263
+ * maximum match interval is 8 years:
264
+ * crontab has '* * 29 2 *' and we are on 1 March 2096:
265
+ * next matching time will be 29 February 2104
266
+ * source: https://github.com/cronie-crond/cronie/blob/0d669551680f733a4bdd6bab082a0b3d6d7f089c/src/cronnext.c#L401-L403
267
+ */
268
+ const maxMatch = luxon.DateTime.now().plus({ years: 8 });
269
+
266
270
  // determine next date
267
271
  while (true) {
268
272
  const diff = date - start;
269
273
 
270
- // hard stop if the current date is after the expected execution
271
- if (Date.now() > timeout) {
274
+ // hard stop if the current date is after the maximum match interval
275
+ if (date > maxMatch) {
272
276
  throw new Error(
273
- `Something went wrong. It took over five seconds to find the next execution time for the cron job.
274
- Please refer to the canonical issue (https://github.com/kelektiv/node-cron/issues/467) and provide the following string if you would like to help debug:
277
+ `Something went wrong. No execution date was found in the next 8 years.
278
+ Please provide the following string if you would like to help debug:
275
279
  Time Zone: ${zone || '""'} - Cron String: ${this} - UTC offset: ${date.offset}
276
280
  - current Date: ${luxon.DateTime.local().toString()}`
277
281
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cron",
3
3
  "description": "Cron jobs for your node",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/kelektiv/node-cron/issues"