@monque/core 1.5.0 → 1.5.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/dist/CHANGELOG.md +6 -0
- package/dist/index.cjs +5 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/scheduler/monque.ts +5 -3
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @monque/core
|
|
2
2
|
|
|
3
|
+
## 1.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#211](https://github.com/ueberBrot/monque/pull/211) [`7181215`](https://github.com/ueberBrot/monque/commit/7181215abac2b5cd231c63f10bf718f0314cc09f) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Close shutdown race condition window by stopping timers before setting isRunning flag
|
|
8
|
+
|
|
3
9
|
## 1.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let mongodb = require("mongodb");
|
|
3
3
|
let cron_parser = require("cron-parser");
|
|
4
4
|
let node_crypto = require("node:crypto");
|
|
5
5
|
let node_events = require("node:events");
|
|
6
|
-
|
|
7
6
|
//#region src/jobs/document-to-persisted-job.ts
|
|
8
7
|
/**
|
|
9
8
|
* Convert a raw MongoDB document to a strongly-typed {@link PersistedJob}.
|
|
@@ -36,7 +35,6 @@ function documentToPersistedJob(doc) {
|
|
|
36
35
|
if (doc["uniqueKey"] !== void 0) job.uniqueKey = doc["uniqueKey"];
|
|
37
36
|
return job;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
39
|
//#region src/jobs/types.ts
|
|
42
40
|
/**
|
|
@@ -75,7 +73,6 @@ const CursorDirection = {
|
|
|
75
73
|
FORWARD: "forward",
|
|
76
74
|
BACKWARD: "backward"
|
|
77
75
|
};
|
|
78
|
-
|
|
79
76
|
//#endregion
|
|
80
77
|
//#region src/jobs/guards.ts
|
|
81
78
|
/**
|
|
@@ -288,7 +285,6 @@ function isCancelledJob(job) {
|
|
|
288
285
|
function isRecurringJob(job) {
|
|
289
286
|
return job.repeatInterval !== void 0 && job.repeatInterval !== null;
|
|
290
287
|
}
|
|
291
|
-
|
|
292
288
|
//#endregion
|
|
293
289
|
//#region src/shared/errors.ts
|
|
294
290
|
/**
|
|
@@ -506,7 +502,6 @@ var PayloadTooLargeError = class PayloadTooLargeError extends MonqueError {
|
|
|
506
502
|
if (Error.captureStackTrace) Error.captureStackTrace(this, PayloadTooLargeError);
|
|
507
503
|
}
|
|
508
504
|
};
|
|
509
|
-
|
|
510
505
|
//#endregion
|
|
511
506
|
//#region src/shared/utils/backoff.ts
|
|
512
507
|
/**
|
|
@@ -548,7 +543,7 @@ const DEFAULT_MAX_BACKOFF_DELAY = 1440 * 60 * 1e3;
|
|
|
548
543
|
* ```
|
|
549
544
|
*/
|
|
550
545
|
function calculateBackoff(failCount, baseInterval = DEFAULT_BASE_INTERVAL, maxDelay) {
|
|
551
|
-
const effectiveMaxDelay = maxDelay ??
|
|
546
|
+
const effectiveMaxDelay = maxDelay ?? 864e5;
|
|
552
547
|
let delay = 2 ** failCount * baseInterval;
|
|
553
548
|
if (delay > effectiveMaxDelay) delay = effectiveMaxDelay;
|
|
554
549
|
return new Date(Date.now() + delay);
|
|
@@ -562,12 +557,11 @@ function calculateBackoff(failCount, baseInterval = DEFAULT_BASE_INTERVAL, maxDe
|
|
|
562
557
|
* @returns The delay in milliseconds
|
|
563
558
|
*/
|
|
564
559
|
function calculateBackoffDelay(failCount, baseInterval = DEFAULT_BASE_INTERVAL, maxDelay) {
|
|
565
|
-
const effectiveMaxDelay = maxDelay ??
|
|
560
|
+
const effectiveMaxDelay = maxDelay ?? 864e5;
|
|
566
561
|
let delay = 2 ** failCount * baseInterval;
|
|
567
562
|
if (delay > effectiveMaxDelay) delay = effectiveMaxDelay;
|
|
568
563
|
return delay;
|
|
569
564
|
}
|
|
570
|
-
|
|
571
565
|
//#endregion
|
|
572
566
|
//#region src/shared/utils/cron.ts
|
|
573
567
|
/**
|
|
@@ -621,7 +615,6 @@ function validateCronExpression(expression) {
|
|
|
621
615
|
function handleCronParseError(expression, error) {
|
|
622
616
|
throw new InvalidCronError(expression, `Invalid cron expression "${expression}": ${error instanceof Error ? error.message : "Unknown parsing error"}. Expected 5-field format: "minute hour day-of-month month day-of-week" or predefined expression (e.g. @daily). Example: "0 9 * * 1" (every Monday at 9am)`);
|
|
623
617
|
}
|
|
624
|
-
|
|
625
618
|
//#endregion
|
|
626
619
|
//#region src/shared/utils/error.ts
|
|
627
620
|
/**
|
|
@@ -654,7 +647,6 @@ function toError(value) {
|
|
|
654
647
|
return /* @__PURE__ */ new Error(`Unserializable value (${detail})`);
|
|
655
648
|
}
|
|
656
649
|
}
|
|
657
|
-
|
|
658
650
|
//#endregion
|
|
659
651
|
//#region src/scheduler/helpers.ts
|
|
660
652
|
/**
|
|
@@ -720,7 +712,6 @@ function decodeCursor(cursor) {
|
|
|
720
712
|
throw new InvalidCursorError("Invalid cursor payload");
|
|
721
713
|
}
|
|
722
714
|
}
|
|
723
|
-
|
|
724
715
|
//#endregion
|
|
725
716
|
//#region src/scheduler/services/change-stream-handler.ts
|
|
726
717
|
/**
|
|
@@ -876,7 +867,6 @@ var ChangeStreamHandler = class {
|
|
|
876
867
|
return this.usingChangeStreams;
|
|
877
868
|
}
|
|
878
869
|
};
|
|
879
|
-
|
|
880
870
|
//#endregion
|
|
881
871
|
//#region src/scheduler/services/job-manager.ts
|
|
882
872
|
/**
|
|
@@ -1169,7 +1159,6 @@ var JobManager = class {
|
|
|
1169
1159
|
}
|
|
1170
1160
|
}
|
|
1171
1161
|
};
|
|
1172
|
-
|
|
1173
1162
|
//#endregion
|
|
1174
1163
|
//#region src/scheduler/services/job-processor.ts
|
|
1175
1164
|
/**
|
|
@@ -1474,7 +1463,6 @@ var JobProcessor = class {
|
|
|
1474
1463
|
} });
|
|
1475
1464
|
}
|
|
1476
1465
|
};
|
|
1477
|
-
|
|
1478
1466
|
//#endregion
|
|
1479
1467
|
//#region src/scheduler/services/job-query.ts
|
|
1480
1468
|
/**
|
|
@@ -1778,7 +1766,6 @@ var JobQueryService = class JobQueryService {
|
|
|
1778
1766
|
}
|
|
1779
1767
|
}
|
|
1780
1768
|
};
|
|
1781
|
-
|
|
1782
1769
|
//#endregion
|
|
1783
1770
|
//#region src/scheduler/services/job-scheduler.ts
|
|
1784
1771
|
/**
|
|
@@ -2009,7 +1996,6 @@ var JobScheduler = class {
|
|
|
2009
1996
|
}
|
|
2010
1997
|
}
|
|
2011
1998
|
};
|
|
2012
|
-
|
|
2013
1999
|
//#endregion
|
|
2014
2000
|
//#region src/scheduler/services/lifecycle-manager.ts
|
|
2015
2001
|
/**
|
|
@@ -2117,7 +2103,6 @@ var LifecycleManager = class {
|
|
|
2117
2103
|
if (deletions.length > 0) await Promise.all(deletions);
|
|
2118
2104
|
}
|
|
2119
2105
|
};
|
|
2120
|
-
|
|
2121
2106
|
//#endregion
|
|
2122
2107
|
//#region src/scheduler/monque.ts
|
|
2123
2108
|
/**
|
|
@@ -3039,12 +3024,12 @@ var Monque = class extends node_events.EventEmitter {
|
|
|
3039
3024
|
*/
|
|
3040
3025
|
async stop() {
|
|
3041
3026
|
if (!this.isRunning) return;
|
|
3027
|
+
this.lifecycleManager.stopTimers();
|
|
3042
3028
|
this.isRunning = false;
|
|
3043
3029
|
this._query?.clearStatsCache();
|
|
3044
3030
|
try {
|
|
3045
3031
|
await this.changeStreamHandler.close();
|
|
3046
3032
|
} catch {}
|
|
3047
|
-
this.lifecycleManager.stopTimers();
|
|
3048
3033
|
if (this.getActiveJobs().length === 0) return;
|
|
3049
3034
|
let checkInterval;
|
|
3050
3035
|
const waitForJobs = new Promise((resolve) => {
|
|
@@ -3166,7 +3151,6 @@ var Monque = class extends node_events.EventEmitter {
|
|
|
3166
3151
|
return super.off(event, listener);
|
|
3167
3152
|
}
|
|
3168
3153
|
};
|
|
3169
|
-
|
|
3170
3154
|
//#endregion
|
|
3171
3155
|
exports.AggregationTimeoutError = AggregationTimeoutError;
|
|
3172
3156
|
exports.ConnectionError = ConnectionError;
|
|
@@ -3194,4 +3178,5 @@ exports.isProcessingJob = isProcessingJob;
|
|
|
3194
3178
|
exports.isRecurringJob = isRecurringJob;
|
|
3195
3179
|
exports.isValidJobStatus = isValidJobStatus;
|
|
3196
3180
|
exports.validateCronExpression = validateCronExpression;
|
|
3181
|
+
|
|
3197
3182
|
//# sourceMappingURL=index.cjs.map
|