bullmq 6.3.4 → 6.3.6
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/bun-redis-client.js +41 -7
- package/dist/cjs/classes/redis-queue-backend.js +0 -2
- package/dist/cjs/commands/includes/fetchNextJob.lua +1 -2
- package/dist/cjs/commands/includes/isQueuePaused.lua +1 -1
- package/dist/cjs/commands/{moveToDelayed-12.lua → moveToDelayed-11.lua} +2 -3
- package/dist/cjs/commands/moveToFinished-14.lua +1 -1
- package/dist/{esm/commands/reprocessJob-8.lua → cjs/commands/reprocessJob-7.lua} +4 -5
- package/dist/cjs/scripts/addJobScheduler-11.js +1 -1
- package/dist/cjs/scripts/index.js +2 -2
- package/dist/cjs/scripts/{moveToDelayed-12.js → moveToDelayed-11.js} +4 -6
- package/dist/cjs/scripts/moveToFinished-14.js +2 -3
- package/dist/cjs/scripts/{reprocessJob-8.js → reprocessJob-7.js} +5 -6
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/bun-redis-client.js +41 -7
- package/dist/esm/classes/redis-queue-backend.js +0 -2
- package/dist/esm/commands/includes/fetchNextJob.lua +1 -2
- package/dist/esm/commands/includes/isQueuePaused.lua +1 -1
- package/dist/esm/commands/{moveToDelayed-12.lua → moveToDelayed-11.lua} +2 -3
- package/dist/esm/commands/moveToFinished-14.lua +1 -1
- package/dist/{cjs/commands/reprocessJob-8.lua → esm/commands/reprocessJob-7.lua} +4 -5
- package/dist/esm/scripts/addJobScheduler-11.js +1 -1
- package/dist/esm/scripts/index.d.ts +2 -2
- package/dist/esm/scripts/index.js +2 -2
- package/dist/esm/scripts/{moveToDelayed-12.js → moveToDelayed-11.js} +4 -6
- package/dist/esm/scripts/moveToFinished-14.js +2 -3
- package/dist/esm/scripts/{reprocessJob-8.js → reprocessJob-7.js} +5 -6
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +11 -12
- /package/dist/esm/scripts/{moveToDelayed-12.d.ts → moveToDelayed-11.d.ts} +0 -0
- /package/dist/esm/scripts/{reprocessJob-8.d.ts → reprocessJob-7.d.ts} +0 -0
|
@@ -218,11 +218,11 @@ class BunRedisAdapter extends events_1.EventEmitter {
|
|
|
218
218
|
async connect() {
|
|
219
219
|
var _a, _b;
|
|
220
220
|
// A duplicate created with a `rawFactory` builds its raw client lazily on
|
|
221
|
-
// the first connect (Bun's native `duplicate()` is async).
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this.
|
|
221
|
+
// the first connect (Bun's native `duplicate()` is async). Concurrent
|
|
222
|
+
// connect()/_ensureRaw() share one in-flight materialization so we don't
|
|
223
|
+
// create two native clients and overwrite an unclosed raw.
|
|
224
|
+
if (!this.raw && (this.rawFactory || this.materializing)) {
|
|
225
|
+
await this._materializeRaw();
|
|
226
226
|
}
|
|
227
227
|
const replaceRaw = this.hasConnected && (this.closed || !this.raw.connected);
|
|
228
228
|
if (this.reconnectTimer) {
|
|
@@ -394,6 +394,36 @@ class BunRedisAdapter extends events_1.EventEmitter {
|
|
|
394
394
|
const Ctor = src.constructor;
|
|
395
395
|
return new Ctor(src.url);
|
|
396
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Materialize a lazily-created raw client (duplicate `rawFactory`).
|
|
399
|
+
* Concurrent callers share the in-flight promise so the factory runs once.
|
|
400
|
+
*/
|
|
401
|
+
_materializeRaw() {
|
|
402
|
+
if (this.raw) {
|
|
403
|
+
return Promise.resolve(this.raw);
|
|
404
|
+
}
|
|
405
|
+
if (this.materializing) {
|
|
406
|
+
return this.materializing;
|
|
407
|
+
}
|
|
408
|
+
const factory = this.rawFactory;
|
|
409
|
+
if (!factory) {
|
|
410
|
+
return Promise.resolve(this.raw);
|
|
411
|
+
}
|
|
412
|
+
const materializing = factory()
|
|
413
|
+
.then(raw => {
|
|
414
|
+
this.raw = raw;
|
|
415
|
+
this.rawFactory = undefined;
|
|
416
|
+
this._setupCallbacks();
|
|
417
|
+
return raw;
|
|
418
|
+
})
|
|
419
|
+
.finally(() => {
|
|
420
|
+
if (this.materializing === materializing) {
|
|
421
|
+
this.materializing = undefined;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
this.materializing = materializing;
|
|
425
|
+
return materializing;
|
|
426
|
+
}
|
|
397
427
|
/**
|
|
398
428
|
* Return the raw client, materializing it first when this adapter is a
|
|
399
429
|
* lazily-initialized duplicate (created via `duplicate()` with a
|
|
@@ -413,9 +443,13 @@ class BunRedisAdapter extends events_1.EventEmitter {
|
|
|
413
443
|
// on first connect. Rebuilding from `this.raw.url` is not possible because
|
|
414
444
|
// Bun never exposes the URL, which previously sent duplicates to the
|
|
415
445
|
// wrong (default) server (#4582).
|
|
416
|
-
|
|
446
|
+
//
|
|
447
|
+
// Do not close over `this.raw`: a duplicate may not have materialized its
|
|
448
|
+
// raw client yet, so nested `duplicate().duplicate()` would capture
|
|
449
|
+
// undefined and throw in `_duplicateRaw` (#4706). Resolve the parent raw
|
|
450
|
+
// lazily, matching reconnect's fallback to `rawFactory`.
|
|
417
451
|
const adapter = new BunRedisAdapter(undefined, {
|
|
418
|
-
rawFactory: () => this._duplicateRaw(
|
|
452
|
+
rawFactory: async () => this._duplicateRaw(await this._ensureRaw()),
|
|
419
453
|
});
|
|
420
454
|
// Copy registered scripts to the duplicate
|
|
421
455
|
for (const [name, script] of this.scripts) {
|
|
@@ -1057,7 +1057,6 @@ class RedisQueueBackend extends events_1.EventEmitter {
|
|
|
1057
1057
|
queueKeys.stalled,
|
|
1058
1058
|
queueKeys.wait,
|
|
1059
1059
|
queueKeys.limiter,
|
|
1060
|
-
queueKeys.paused,
|
|
1061
1060
|
queueKeys.pc,
|
|
1062
1061
|
];
|
|
1063
1062
|
const fetchNext = opts.fetchNext && !this.queue.closing ? 1 : 0;
|
|
@@ -1301,7 +1300,6 @@ class RedisQueueBackend extends events_1.EventEmitter {
|
|
|
1301
1300
|
this.queue.toKey(state),
|
|
1302
1301
|
this.queue.keys.wait,
|
|
1303
1302
|
this.queue.keys.meta,
|
|
1304
|
-
this.queue.keys.paused,
|
|
1305
1303
|
this.queue.keys.active,
|
|
1306
1304
|
this.queue.keys.marker,
|
|
1307
1305
|
];
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
eventStreamKey - event stream key
|
|
11
11
|
rateLimiterKey - rate limiter key
|
|
12
12
|
delayedKey - delayed sorted set key
|
|
13
|
-
pausedKey - paused list key
|
|
14
13
|
metaKey - meta hash key
|
|
15
14
|
pcKey - priority counter key
|
|
16
15
|
markerKey - marker key
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
--- @include "promoteDelayedJobs"
|
|
32
31
|
|
|
33
32
|
local function fetchNextJob(waitKey, activeKey, prioritizedKey, eventStreamKey,
|
|
34
|
-
rateLimiterKey, delayedKey,
|
|
33
|
+
rateLimiterKey, delayedKey, metaKey, pcKey, markerKey, prefix,
|
|
35
34
|
timestamp, opts)
|
|
36
35
|
|
|
37
36
|
local isPausedOrMaxed, rateLimitMax, rateLimitDuration =
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
--[[
|
|
2
|
-
Function to check for the meta.paused
|
|
2
|
+
Function to check for the meta.paused attribute to decide if we are paused or not
|
|
3
3
|
(since an empty list and !EXISTS are not really the same).
|
|
4
4
|
]]
|
|
5
5
|
local function isQueuePaused(queueMetaKey)
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
KEYS[8] stalled key
|
|
13
13
|
KEYS[9] wait key
|
|
14
14
|
KEYS[10] rate limiter key
|
|
15
|
-
KEYS[11]
|
|
16
|
-
KEYS[12] pc priority counter
|
|
15
|
+
KEYS[11] pc priority counter
|
|
17
16
|
|
|
18
17
|
ARGV[1] key prefix
|
|
19
18
|
ARGV[2] timestamp
|
|
@@ -81,7 +80,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
81
80
|
if (ARGV[8] == "1") then
|
|
82
81
|
local opts = cmsgpack.unpack(ARGV[9])
|
|
83
82
|
local result = fetchNextJob(KEYS[9], KEYS[2], KEYS[3], KEYS[6],
|
|
84
|
-
KEYS[10], KEYS[4],
|
|
83
|
+
KEYS[10], KEYS[4], metaKey, KEYS[11], markerKey,
|
|
85
84
|
ARGV[1], ARGV[2], opts)
|
|
86
85
|
if result and type(result[1]) == "table" then
|
|
87
86
|
return result
|
|
@@ -213,7 +213,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
213
213
|
-- and not rate limited.
|
|
214
214
|
if (ARGV[6] == "1") then
|
|
215
215
|
local result = fetchNextJob(KEYS[1], KEYS[2], KEYS[3], eventStreamKey,
|
|
216
|
-
KEYS[6], KEYS[7],
|
|
216
|
+
KEYS[6], KEYS[7], metaKey, KEYS[10], KEYS[14], prefix,
|
|
217
217
|
timestamp, opts)
|
|
218
218
|
if result then
|
|
219
219
|
return result
|
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
KEYS[3] job state
|
|
8
8
|
KEYS[4] wait key
|
|
9
9
|
KEYS[5] meta
|
|
10
|
-
KEYS[6]
|
|
11
|
-
KEYS[7]
|
|
12
|
-
KEYS[8] marker key
|
|
10
|
+
KEYS[6] active key
|
|
11
|
+
KEYS[7] marker key
|
|
13
12
|
|
|
14
13
|
ARGV[1] job.id
|
|
15
14
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
|
@@ -46,8 +45,8 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
46
45
|
|
|
47
46
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", ARGV[3], unpack(attributesToRemove))
|
|
48
47
|
|
|
49
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[
|
|
50
|
-
addJobInTargetList(KEYS[4], KEYS[
|
|
48
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
49
|
+
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
51
50
|
|
|
52
51
|
local parentKey = rcall("HGET", jobKey, "parentKey")
|
|
53
52
|
|
|
@@ -244,7 +244,7 @@ local function getOrSetMaxEvents(metaKey)
|
|
|
244
244
|
return maxEvents
|
|
245
245
|
end
|
|
246
246
|
--[[
|
|
247
|
-
Function to check for the meta.paused
|
|
247
|
+
Function to check for the meta.paused attribute to decide if we are paused or not
|
|
248
248
|
(since an empty list and !EXISTS are not really the same).
|
|
249
249
|
]]
|
|
250
250
|
local function isQueuePaused(queueMetaKey)
|
|
@@ -30,7 +30,7 @@ tslib_1.__exportStar(require("./moveJobFromActiveToWait-9"), exports);
|
|
|
30
30
|
tslib_1.__exportStar(require("./moveJobsToWait-8"), exports);
|
|
31
31
|
tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
|
|
32
32
|
tslib_1.__exportStar(require("./moveToActive-11"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./moveToDelayed-
|
|
33
|
+
tslib_1.__exportStar(require("./moveToDelayed-11"), exports);
|
|
34
34
|
tslib_1.__exportStar(require("./moveToFinished-14"), exports);
|
|
35
35
|
tslib_1.__exportStar(require("./moveToWaitingChildren-7"), exports);
|
|
36
36
|
tslib_1.__exportStar(require("./obliterate-2"), exports);
|
|
@@ -44,7 +44,7 @@ tslib_1.__exportStar(require("./removeJob-2"), exports);
|
|
|
44
44
|
tslib_1.__exportStar(require("./removeJobScheduler-3"), exports);
|
|
45
45
|
tslib_1.__exportStar(require("./removeOrphanedJobs-1"), exports);
|
|
46
46
|
tslib_1.__exportStar(require("./removeUnprocessedChildren-2"), exports);
|
|
47
|
-
tslib_1.__exportStar(require("./reprocessJob-
|
|
47
|
+
tslib_1.__exportStar(require("./reprocessJob-7"), exports);
|
|
48
48
|
tslib_1.__exportStar(require("./retryJob-11"), exports);
|
|
49
49
|
tslib_1.__exportStar(require("./saveStacktrace-1"), exports);
|
|
50
50
|
tslib_1.__exportStar(require("./updateData-1"), exports);
|
|
@@ -14,8 +14,7 @@ const content = `--[[
|
|
|
14
14
|
KEYS[8] stalled key
|
|
15
15
|
KEYS[9] wait key
|
|
16
16
|
KEYS[10] rate limiter key
|
|
17
|
-
KEYS[11]
|
|
18
|
-
KEYS[12] pc priority counter
|
|
17
|
+
KEYS[11] pc priority counter
|
|
19
18
|
ARGV[1] key prefix
|
|
20
19
|
ARGV[2] timestamp
|
|
21
20
|
ARGV[3] the id of the job
|
|
@@ -69,7 +68,6 @@ end
|
|
|
69
68
|
eventStreamKey - event stream key
|
|
70
69
|
rateLimiterKey - rate limiter key
|
|
71
70
|
delayedKey - delayed sorted set key
|
|
72
|
-
pausedKey - paused list key
|
|
73
71
|
metaKey - meta hash key
|
|
74
72
|
pcKey - priority counter key
|
|
75
73
|
markerKey - marker key
|
|
@@ -234,7 +232,7 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
|
|
|
234
232
|
end
|
|
235
233
|
end
|
|
236
234
|
local function fetchNextJob(waitKey, activeKey, prioritizedKey, eventStreamKey,
|
|
237
|
-
rateLimiterKey, delayedKey,
|
|
235
|
+
rateLimiterKey, delayedKey, metaKey, pcKey, markerKey, prefix,
|
|
238
236
|
timestamp, opts)
|
|
239
237
|
local isPausedOrMaxed, rateLimitMax, rateLimitDuration =
|
|
240
238
|
getQueueMetadata(metaKey, activeKey, waitKey)
|
|
@@ -380,7 +378,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
380
378
|
if (ARGV[8] == "1") then
|
|
381
379
|
local opts = cmsgpack.unpack(ARGV[9])
|
|
382
380
|
local result = fetchNextJob(KEYS[9], KEYS[2], KEYS[3], KEYS[6],
|
|
383
|
-
KEYS[10], KEYS[4],
|
|
381
|
+
KEYS[10], KEYS[4], metaKey, KEYS[11], markerKey,
|
|
384
382
|
ARGV[1], ARGV[2], opts)
|
|
385
383
|
if result and type(result[1]) == "table" then
|
|
386
384
|
return result
|
|
@@ -396,5 +394,5 @@ end
|
|
|
396
394
|
exports.moveToDelayed = {
|
|
397
395
|
name: 'moveToDelayed',
|
|
398
396
|
content,
|
|
399
|
-
keys:
|
|
397
|
+
keys: 11,
|
|
400
398
|
};
|
|
@@ -119,7 +119,6 @@ end
|
|
|
119
119
|
eventStreamKey - event stream key
|
|
120
120
|
rateLimiterKey - rate limiter key
|
|
121
121
|
delayedKey - delayed sorted set key
|
|
122
|
-
pausedKey - paused list key
|
|
123
122
|
metaKey - meta hash key
|
|
124
123
|
pcKey - priority counter key
|
|
125
124
|
markerKey - marker key
|
|
@@ -296,7 +295,7 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
|
|
|
296
295
|
end
|
|
297
296
|
end
|
|
298
297
|
local function fetchNextJob(waitKey, activeKey, prioritizedKey, eventStreamKey,
|
|
299
|
-
rateLimiterKey, delayedKey,
|
|
298
|
+
rateLimiterKey, delayedKey, metaKey, pcKey, markerKey, prefix,
|
|
300
299
|
timestamp, opts)
|
|
301
300
|
local isPausedOrMaxed, rateLimitMax, rateLimitDuration =
|
|
302
301
|
getQueueMetadata(metaKey, activeKey, waitKey)
|
|
@@ -1017,7 +1016,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
1017
1016
|
-- and not rate limited.
|
|
1018
1017
|
if (ARGV[6] == "1") then
|
|
1019
1018
|
local result = fetchNextJob(KEYS[1], KEYS[2], KEYS[3], eventStreamKey,
|
|
1020
|
-
KEYS[6], KEYS[7],
|
|
1019
|
+
KEYS[6], KEYS[7], metaKey, KEYS[10], KEYS[14], prefix,
|
|
1021
1020
|
timestamp, opts)
|
|
1022
1021
|
if result then
|
|
1023
1022
|
return result
|
|
@@ -9,9 +9,8 @@ const content = `--[[
|
|
|
9
9
|
KEYS[3] job state
|
|
10
10
|
KEYS[4] wait key
|
|
11
11
|
KEYS[5] meta
|
|
12
|
-
KEYS[6]
|
|
13
|
-
KEYS[7]
|
|
14
|
-
KEYS[8] marker key
|
|
12
|
+
KEYS[6] active key
|
|
13
|
+
KEYS[7] marker key
|
|
15
14
|
ARGV[1] job.id
|
|
16
15
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
|
17
16
|
ARGV[3] propVal - failedReason/returnvalue
|
|
@@ -80,8 +79,8 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
80
79
|
table.insert(attributesToRemove, "ats")
|
|
81
80
|
end
|
|
82
81
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", ARGV[3], unpack(attributesToRemove))
|
|
83
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[
|
|
84
|
-
addJobInTargetList(KEYS[4], KEYS[
|
|
82
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
83
|
+
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
85
84
|
local parentKey = rcall("HGET", jobKey, "parentKey")
|
|
86
85
|
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
87
86
|
if ARGV[4] == "failed" then
|
|
@@ -110,5 +109,5 @@ end
|
|
|
110
109
|
exports.reprocessJob = {
|
|
111
110
|
name: 'reprocessJob',
|
|
112
111
|
content,
|
|
113
|
-
keys:
|
|
112
|
+
keys: 7,
|
|
114
113
|
};
|