bullmq 5.76.9 → 5.76.11
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/cjs/classes/async-fifo-queue.js +38 -0
- package/dist/cjs/classes/flow-producer.js +4 -3
- package/dist/cjs/classes/job.js +6 -0
- package/dist/cjs/classes/queue-base.js +4 -4
- package/dist/cjs/classes/queue.js +1 -1
- package/dist/cjs/classes/worker.js +5 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils/index.js +3 -2
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/async-fifo-queue.d.ts +38 -0
- package/dist/esm/classes/async-fifo-queue.js +38 -0
- package/dist/esm/classes/flow-producer.d.ts +4 -3
- package/dist/esm/classes/flow-producer.js +4 -3
- package/dist/esm/classes/job.js +6 -0
- package/dist/esm/classes/queue-base.d.ts +4 -4
- package/dist/esm/classes/queue-base.js +4 -4
- package/dist/esm/classes/queue.d.ts +1 -1
- package/dist/esm/classes/queue.js +1 -1
- package/dist/esm/classes/worker.js +5 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/index.d.ts +3 -2
- package/dist/esm/utils/index.js +3 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +5 -5
|
@@ -63,6 +63,13 @@ class AsyncFifoQueue {
|
|
|
63
63
|
this.pending = new Set();
|
|
64
64
|
this.newPromise();
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Adds a promise to the queue. When it resolves, its value is enqueued
|
|
68
|
+
* and, if a consumer is waiting via {@link fetch}, the next pending
|
|
69
|
+
* promise is resolved with the value.
|
|
70
|
+
*
|
|
71
|
+
* @param promise - The asynchronous operation to add to the queue.
|
|
72
|
+
*/
|
|
66
73
|
add(promise) {
|
|
67
74
|
this.pending.add(promise);
|
|
68
75
|
promise
|
|
@@ -82,15 +89,38 @@ class AsyncFifoQueue {
|
|
|
82
89
|
this.rejectPromise(err);
|
|
83
90
|
});
|
|
84
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Waits for all currently pending promises to settle.
|
|
94
|
+
*
|
|
95
|
+
* @returns A promise that resolves once every in-flight promise has resolved.
|
|
96
|
+
*/
|
|
85
97
|
async waitAll() {
|
|
86
98
|
await Promise.all(this.pending);
|
|
87
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the total number of items currently tracked by the queue,
|
|
102
|
+
* including both pending (in-flight) promises and resolved items that
|
|
103
|
+
* have not yet been fetched.
|
|
104
|
+
*
|
|
105
|
+
* @returns The sum of pending and queued items.
|
|
106
|
+
*/
|
|
88
107
|
numTotal() {
|
|
89
108
|
return this.pending.size + this.queue.length;
|
|
90
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the number of promises that are still pending (in-flight).
|
|
112
|
+
*
|
|
113
|
+
* @returns The number of unresolved promises currently in the queue.
|
|
114
|
+
*/
|
|
91
115
|
numPending() {
|
|
92
116
|
return this.pending.size;
|
|
93
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the number of items that have already resolved but have not
|
|
120
|
+
* yet been fetched by a consumer.
|
|
121
|
+
*
|
|
122
|
+
* @returns The number of resolved items waiting to be consumed.
|
|
123
|
+
*/
|
|
94
124
|
numQueued() {
|
|
95
125
|
return this.queue.length;
|
|
96
126
|
}
|
|
@@ -111,6 +141,14 @@ class AsyncFifoQueue {
|
|
|
111
141
|
async wait() {
|
|
112
142
|
return this.nextPromise;
|
|
113
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Fetches the next resolved item from the queue in FIFO order. If no
|
|
146
|
+
* items are currently resolved but pending promises exist, it waits
|
|
147
|
+
* until the next one resolves.
|
|
148
|
+
*
|
|
149
|
+
* @returns The next resolved value, or `undefined` if there are no
|
|
150
|
+
* pending or queued items.
|
|
151
|
+
*/
|
|
114
152
|
async fetch() {
|
|
115
153
|
var _a;
|
|
116
154
|
if (this.pending.size === 0 && this.queue.length === 0) {
|
|
@@ -336,9 +336,10 @@ class FlowProducer extends events_1.EventEmitter {
|
|
|
336
336
|
* Helper factory method that creates a queue-like object
|
|
337
337
|
* required to create jobs in any queue.
|
|
338
338
|
*
|
|
339
|
-
* @param node -
|
|
340
|
-
* @param queueKeys -
|
|
341
|
-
* @
|
|
339
|
+
* @param node - The flow node containing the queue name and other job options.
|
|
340
|
+
* @param queueKeys - The queue keys helper used to resolve key names.
|
|
341
|
+
* @param prefix - The Redis key prefix used for the queue.
|
|
342
|
+
* @returns A queue-like object with the client, keys, and options needed to create jobs.
|
|
342
343
|
*/
|
|
343
344
|
queueFromNode(node, queueKeys, prefix) {
|
|
344
345
|
return {
|
package/dist/cjs/classes/job.js
CHANGED
|
@@ -207,9 +207,15 @@ class Job {
|
|
|
207
207
|
if (json.parentKey) {
|
|
208
208
|
job.parentKey = json.parentKey;
|
|
209
209
|
}
|
|
210
|
+
else {
|
|
211
|
+
job.parentKey = undefined;
|
|
212
|
+
}
|
|
210
213
|
if (json.parent) {
|
|
211
214
|
job.parent = JSON.parse(json.parent);
|
|
212
215
|
}
|
|
216
|
+
else {
|
|
217
|
+
job.parent = undefined;
|
|
218
|
+
}
|
|
213
219
|
if (json.pb) {
|
|
214
220
|
job.processedBy = json.pb;
|
|
215
221
|
}
|
|
@@ -83,8 +83,8 @@ class QueueBase extends events_1.EventEmitter {
|
|
|
83
83
|
* Emits an event. Normally used by subclasses to emit events.
|
|
84
84
|
*
|
|
85
85
|
* @param event - The emitted event.
|
|
86
|
-
* @param args -
|
|
87
|
-
* @returns
|
|
86
|
+
* @param args - The arguments to pass to the event listeners.
|
|
87
|
+
* @returns True if the event had listeners, false otherwise.
|
|
88
88
|
*/
|
|
89
89
|
emit(event, ...args) {
|
|
90
90
|
try {
|
|
@@ -152,8 +152,8 @@ class QueueBase extends events_1.EventEmitter {
|
|
|
152
152
|
* @param operation - operation name (such as add, process, etc)
|
|
153
153
|
* @param destination - destination name (normally the queue name)
|
|
154
154
|
* @param callback - code to wrap with telemetry
|
|
155
|
-
* @param srcPropagationMetadata -
|
|
156
|
-
* @returns
|
|
155
|
+
* @param srcPropagationMetadata - The source propagation metadata for telemetry context.
|
|
156
|
+
* @returns The result of the callback function.
|
|
157
157
|
*/
|
|
158
158
|
trace(spanKind, operation, destination, callback, srcPropagationMetadata) {
|
|
159
159
|
return (0, utils_1.trace)(this.opts.telemetry, spanKind, this.name, operation, destination, callback, srcPropagationMetadata);
|
|
@@ -631,7 +631,7 @@ class Queue extends queue_getters_1.QueueGetters {
|
|
|
631
631
|
/**
|
|
632
632
|
* Trim the event stream to an approximately maxLength.
|
|
633
633
|
*
|
|
634
|
-
* @param maxLength -
|
|
634
|
+
* @param maxLength - The approximate maximum length, or target length, of the event stream.
|
|
635
635
|
*/
|
|
636
636
|
async trimEvents(maxLength) {
|
|
637
637
|
return this.trace(enums_1.SpanKind.INTERNAL, 'trimEvents', this.name, async (span) => {
|
|
@@ -646,16 +646,20 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
646
646
|
this.limitUntil = rateLimitTtl > 0 ? Date.now() + rateLimitTtl : 0;
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
|
+
const fetchNext = fetchNextCallback() && !(this.closing || this.paused);
|
|
649
650
|
if (err instanceof errors_1.DelayedError ||
|
|
650
651
|
err.name == 'DelayedError' ||
|
|
651
652
|
err instanceof errors_1.WaitingError ||
|
|
652
653
|
err.name == 'WaitingError' ||
|
|
653
654
|
err instanceof errors_1.WaitingChildrenError ||
|
|
654
655
|
err.name == 'WaitingChildrenError') {
|
|
656
|
+
if (!fetchNext) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
655
659
|
const client = await this.client;
|
|
656
660
|
return this.moveToActive(client, token, this.opts.name);
|
|
657
661
|
}
|
|
658
|
-
const result = await job.moveToFailed(err, token,
|
|
662
|
+
const result = await job.moveToFailed(err, token, fetchNext);
|
|
659
663
|
this.emit('failed', job, err, 'active');
|
|
660
664
|
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
661
665
|
[enums_1.TelemetryAttributes.JobFailedReason]: err.message,
|