cron 3.0.0-beta.1 → 3.0.0-beta.3

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,31 @@
1
+ ## [3.0.0-beta.3](https://github.com/kelektiv/node-cron/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2023-08-15)
2
+
3
+
4
+ ### ⚠ Breaking changes
5
+
6
+ * return empty array from nextDates when called without argument (#519)
7
+
8
+ ### 🐛 Bug Fixes
9
+
10
+ * return empty array from nextDates when called without argument ([#519](https://github.com/kelektiv/node-cron/issues/519)) ([e65c3dc](https://github.com/kelektiv/node-cron/commit/e65c3dc6c334b8d4df0da317b75494d78cd5d52b))
11
+
12
+ ## [3.0.0-beta.2](https://github.com/kelektiv/node-cron/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2023-08-15)
13
+
14
+
15
+ ### 🐛 Bug Fixes
16
+
17
+ * 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))
18
+
19
+
20
+ ### 🚨 Tests
21
+
22
+ * update new test for cron standard alignments ([ea56fc1](https://github.com/kelektiv/node-cron/commit/ea56fc1c32905d711b160823fc09f39169dd3efd))
23
+
24
+
25
+ ### ⚙️ Continuous Integrations
26
+
27
+ * **renovate:** configure renovate ([#683](https://github.com/kelektiv/node-cron/issues/683)) ([9dbe962](https://github.com/kelektiv/node-cron/commit/9dbe962fad1c8b1b020441bce84ab91b1a7b4415))
28
+
1
29
  ## [3.0.0-beta.1](https://github.com/kelektiv/node-cron/compare/v2.3.1...v3.0.0-beta.1) (2023-07-23)
2
30
 
3
31
 
@@ -9,6 +37,41 @@
9
37
 
10
38
  * UNIX standard alignments ([#667](https://github.com/kelektiv/node-cron/issues/667)) ([96ef954](https://github.com/kelektiv/node-cron/commit/96ef954998f9c109cc2a969296568b1b56bbbd79))
11
39
 
40
+ ## [2.4.1](https://github.com/kelektiv/node-cron/compare/v2.4.0...v2.4.1) (2023-08-14)
41
+
42
+
43
+ ### 🐛 Bug Fixes
44
+
45
+ * 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))
46
+
47
+
48
+ ### ⚙️ Continuous Integrations
49
+
50
+ * **renovate:** configure renovate ([#683](https://github.com/kelektiv/node-cron/issues/683)) ([9dbe962](https://github.com/kelektiv/node-cron/commit/9dbe962fad1c8b1b020441bce84ab91b1a7b4415))
51
+
52
+ ## [2.4.0](https://github.com/kelektiv/node-cron/compare/v2.3.0...v2.4.0) (2023-07-24)
53
+
54
+
55
+ ### ✨ Features
56
+
57
+ * import type definitions from [@types](https://github.com/types)/cron ([d8a2f14](https://github.com/kelektiv/node-cron/commit/d8a2f140b59f063897dd20b7bb4dc7f599d2435b))
58
+
59
+
60
+ ### 🐛 Bug Fixes
61
+
62
+ * don't start job in setTime if it wasn't running ([7e26c23](https://github.com/kelektiv/node-cron/commit/7e26c23e06277bfeb04525c71b67703392dbb8b2))
63
+
64
+
65
+ ### 🛠 Builds
66
+
67
+ * **npm:** ship type definitions with releases ([0b663a8](https://github.com/kelektiv/node-cron/commit/0b663a8584f87cbec63042a4c217f43f38869fc4))
68
+
69
+
70
+ ### 🚨 Tests
71
+
72
+ * add test case for [#598](https://github.com/kelektiv/node-cron/issues/598) fix ([4322ef2](https://github.com/kelektiv/node-cron/commit/4322ef29fa8af201aed5cdf8b829d411311fe025))
73
+ * don't stop/start job before using setTime ([f0d5d3f](https://github.com/kelektiv/node-cron/commit/f0d5d3f32eddb8fd77b84438fe471fd374b34566))
74
+
12
75
 
13
76
  ### ⚙️ Continuous Integrations
14
77
 
@@ -19,6 +82,7 @@
19
82
  ### ♻️ Chores
20
83
 
21
84
  * update default branch name ([#678](https://github.com/kelektiv/node-cron/issues/678)) ([7471e95](https://github.com/kelektiv/node-cron/commit/7471e95cb7433b4f29cfa68da0a652ec8cf630b6))
85
+ * wrap setTime tests in describe and move down ([31989e0](https://github.com/kelektiv/node-cron/commit/31989e06f939bf1e9dbc6c0b6fc62c0a7144b9eb))
22
86
 
23
87
  ## [v2.3.1](https://github.com/kelektiv/node-cron/compare/v2.3.0...v2.3.1) (2023-05-25)
24
88
 
package/README.md CHANGED
@@ -52,7 +52,7 @@ As goes with semver, breaking backwards compatibility should be explicit in the
52
52
  var CronJob = require('cron').CronJob;
53
53
  var job = new CronJob(
54
54
  '* * * * * *',
55
- function() {
55
+ function () {
56
56
  console.log('You will see this message every second');
57
57
  },
58
58
  null,
@@ -125,6 +125,7 @@ Parameter Based
125
125
  - `stop` - Stops your job.
126
126
  - `setTime` - Stops and changes the time for the `CronJob`. Param must be a `CronTime`.
127
127
  - `lastDate` - Tells you the last execution date.
128
+ - `nextDate` - Provides the next date that will trigger an `onTick`.
128
129
  - `nextDates` - Provides an array of the next set of dates that will trigger an `onTick`.
129
130
  - `fireOnTick` - Allows you to override the `onTick` calling behavior. This matters so only do this if you have a really good reason to do so.
130
131
  - `addCallback` - Allows you to add `onTick` callbacks.
package/lib/job.js CHANGED
@@ -106,7 +106,7 @@ function CronJob(CronTime, spawn) {
106
106
  CJ.prototype.fireOnTick = fireOnTick;
107
107
 
108
108
  CJ.prototype.nextDates = function (i) {
109
- return this.cronTime.sendAt(i);
109
+ return this.cronTime.sendAt(i || 0);
110
110
  };
111
111
 
112
112
  const start = function () {
package/lib/time.js CHANGED
@@ -260,19 +260,23 @@ function CronTime(luxon) {
260
260
  throw new Error('ERROR: You specified an invalid date.');
261
261
  }
262
262
 
263
- // it shouldn't take more than 5 seconds to find the next execution time
264
- // being very generous with this. Throw error if it takes too long to find the next time to protect from
265
- // infinite loop.
266
- const timeout = Date.now() + 5000;
263
+ /**
264
+ * maximum match interval is 8 years:
265
+ * crontab has '* * 29 2 *' and we are on 1 March 2096:
266
+ * next matching time will be 29 February 2104
267
+ * source: https://github.com/cronie-crond/cronie/blob/0d669551680f733a4bdd6bab082a0b3d6d7f089c/src/cronnext.c#L401-L403
268
+ */
269
+ const maxMatch = luxon.DateTime.now().plus({ years: 8 });
270
+
267
271
  // determine next date
268
272
  while (true) {
269
273
  const diff = date - start;
270
274
 
271
- // hard stop if the current date is after the expected execution
272
- if (Date.now() > timeout) {
275
+ // hard stop if the current date is after the maximum match interval
276
+ if (date > maxMatch) {
273
277
  throw new Error(
274
- `Something went wrong. It took over five seconds to find the next execution time for the cron job.
275
- 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:
278
+ `Something went wrong. No execution date was found in the next 8 years.
279
+ Please provide the following string if you would like to help debug:
276
280
  Time Zone: ${zone || '""'} - Cron String: ${this} - UTC offset: ${date.offset}
277
281
  - current Date: ${luxon.DateTime.local().toString()}`
278
282
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cron",
3
3
  "description": "Cron jobs for your node",
4
- "version": "3.0.0-beta.1",
4
+ "version": "3.0.0-beta.3",
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"