bullmq 5.47.3 → 5.48.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.
Files changed (68) hide show
  1. package/dist/cjs/classes/job.js +16 -5
  2. package/dist/cjs/classes/job.js.map +1 -1
  3. package/dist/cjs/classes/queue-base.js +1 -4
  4. package/dist/cjs/classes/queue-base.js.map +1 -1
  5. package/dist/cjs/classes/queue-events.js.map +1 -1
  6. package/dist/cjs/classes/queue-getters.js +12 -15
  7. package/dist/cjs/classes/queue-getters.js.map +1 -1
  8. package/dist/cjs/classes/queue.js +12 -12
  9. package/dist/cjs/classes/redis-connection.js +1 -1
  10. package/dist/cjs/classes/redis-connection.js.map +1 -1
  11. package/dist/cjs/classes/scripts.js +13 -3
  12. package/dist/cjs/classes/scripts.js.map +1 -1
  13. package/dist/cjs/commands/includes/isLocked.lua +1 -0
  14. package/dist/cjs/commands/includes/removeJobWithChildren.lua +93 -0
  15. package/dist/cjs/commands/removeJob-3.lua +15 -72
  16. package/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
  17. package/dist/cjs/scripts/index.js +1 -0
  18. package/dist/cjs/scripts/index.js.map +1 -1
  19. package/dist/cjs/scripts/removeJob-3.js +83 -55
  20. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  21. package/dist/cjs/scripts/removeUnprocessedChildren-2.js +332 -0
  22. package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -0
  23. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  24. package/dist/cjs/utils.js +1 -0
  25. package/dist/cjs/utils.js.map +1 -1
  26. package/dist/cjs/version.js +1 -1
  27. package/dist/esm/classes/job.d.ts +14 -6
  28. package/dist/esm/classes/job.js +16 -5
  29. package/dist/esm/classes/job.js.map +1 -1
  30. package/dist/esm/classes/queue-base.d.ts +1 -4
  31. package/dist/esm/classes/queue-base.js +1 -4
  32. package/dist/esm/classes/queue-base.js.map +1 -1
  33. package/dist/esm/classes/queue-events.d.ts +32 -31
  34. package/dist/esm/classes/queue-events.js.map +1 -1
  35. package/dist/esm/classes/queue-getters.d.ts +11 -14
  36. package/dist/esm/classes/queue-getters.js +12 -15
  37. package/dist/esm/classes/queue-getters.js.map +1 -1
  38. package/dist/esm/classes/queue.d.ts +12 -12
  39. package/dist/esm/classes/queue.js +12 -12
  40. package/dist/esm/classes/redis-connection.js +1 -1
  41. package/dist/esm/classes/redis-connection.js.map +1 -1
  42. package/dist/esm/classes/scripts.d.ts +2 -1
  43. package/dist/esm/classes/scripts.js +13 -3
  44. package/dist/esm/classes/scripts.js.map +1 -1
  45. package/dist/esm/commands/includes/isLocked.lua +1 -0
  46. package/dist/esm/commands/includes/removeJobWithChildren.lua +93 -0
  47. package/dist/esm/commands/removeJob-3.lua +15 -72
  48. package/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
  49. package/dist/esm/interfaces/queue-options.d.ts +1 -1
  50. package/dist/esm/interfaces/repeat-options.d.ts +1 -1
  51. package/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
  52. package/dist/esm/interfaces/telemetry.d.ts +18 -15
  53. package/dist/esm/interfaces/worker-options.d.ts +10 -10
  54. package/dist/esm/scripts/index.d.ts +1 -0
  55. package/dist/esm/scripts/index.js +1 -0
  56. package/dist/esm/scripts/index.js.map +1 -1
  57. package/dist/esm/scripts/removeJob-3.js +83 -55
  58. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  59. package/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
  60. package/dist/esm/scripts/removeUnprocessedChildren-2.js +329 -0
  61. package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -0
  62. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  63. package/dist/esm/types/job-options.d.ts +1 -1
  64. package/dist/esm/utils.js +1 -0
  65. package/dist/esm/utils.js.map +1 -1
  66. package/dist/esm/version.d.ts +1 -1
  67. package/dist/esm/version.js +1 -1
  68. package/package.json +7 -7
@@ -33,8 +33,8 @@ export interface ContextManager<Context = any> {
33
33
  /**
34
34
  * Creates a new context and sets it as active for the fn passed as last argument
35
35
  *
36
- * @param context -
37
- * @param fn -
36
+ * @param context - the context to set as active
37
+ * @param fn - the function to execute with the context
38
38
  */
39
39
  with<A extends (...args: any[]) => any>(context: Context, fn: A): ReturnType<A>;
40
40
  /**
@@ -46,15 +46,15 @@ export interface ContextManager<Context = any> {
46
46
  * is the mechanism used to propagate the context across a distributed
47
47
  * application.
48
48
  *
49
- * @param context -
49
+ * @param context - the current context
50
50
  */
51
51
  getMetadata(context: Context): string;
52
52
  /**
53
53
  * Creates a new context from a serialized version effectively
54
54
  * linking the new context to the parent context.
55
55
  *
56
- * @param activeContext -
57
- * @param metadata -
56
+ * @param activeContext - the current active context
57
+ * @param metadata - the serialized version of the context
58
58
  */
59
59
  fromMetadata(activeContext: Context, metadata: string): Context;
60
60
  }
@@ -68,9 +68,10 @@ export interface Tracer<Context = any> {
68
68
  * context. If the context is not provided, the current active context should be
69
69
  * used.
70
70
  *
71
- * @param name -
72
- * @param options -
73
- * @param context -
71
+ * @param name - span name
72
+ * @param options - span options
73
+ * @param context - optional context
74
+ * @returns - the created span
74
75
  */
75
76
  startSpan(name: string, options?: SpanOptions, context?: Context): Span;
76
77
  }
@@ -85,33 +86,35 @@ export interface Span<Context = any> {
85
86
  * setSpanOnContext sets the span on the context. This is useful when you want
86
87
  * to propagate the span across the application.
87
88
  *
88
- * @param ctx
89
+ * @param ctx - context to set the span on
90
+ * @returns - the context with the span set on it
89
91
  */
90
92
  setSpanOnContext(ctx: Context): Context;
91
93
  /**
92
94
  * setAttribute sets an attribute on the span.
93
95
  *
94
- * @param ctx
96
+ * @param key - attribute key
97
+ * @param value - attribute value
95
98
  */
96
99
  setAttribute(key: string, value: AttributeValue): void;
97
100
  /**
98
101
  * setAttributes sets multiple attributes on the span.
99
102
  *
100
- * @param attributes
103
+ * @param attributes - attributes to set
101
104
  */
102
105
  setAttributes(attributes: Attributes): void;
103
106
  /**
104
107
  * addEvent adds an event to the span.
105
108
  *
106
- * @param name
107
- * @param attributes
109
+ * @param name - event name
110
+ * @param attributes - event attributes
108
111
  */
109
112
  addEvent(name: string, attributes?: Attributes): void;
110
113
  /**
111
114
  * recordException records an exception on the span.
112
115
  *
113
- * @param exception
114
- * @param time
116
+ * @param exception - exception to record
117
+ * @param time - time to record the exception
115
118
  */
116
119
  recordException(exception: Exception, time?: Time): void;
117
120
  /**
@@ -20,14 +20,14 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
20
20
  /**
21
21
  * Condition to start processor at instance creation.
22
22
  *
23
- * @default true
23
+ * @defaultValue true
24
24
  */
25
25
  autorun?: boolean;
26
26
  /**
27
27
  * Amount of jobs that a single worker is allowed to work on
28
28
  * in parallel.
29
29
  *
30
- * @default 1
30
+ * @defaultValue 1
31
31
  * @see {@link https://docs.bullmq.io/guide/workers/concurrency}
32
32
  */
33
33
  concurrency?: number;
@@ -46,13 +46,13 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
46
46
  * to the `wait` state. If this is exceeded, the job is moved
47
47
  * to `failed`.
48
48
  *
49
- * @default 1
49
+ * @defaultValue 1
50
50
  */
51
51
  maxStalledCount?: number;
52
52
  /**
53
53
  * Number of milliseconds between stallness checks.
54
54
  *
55
- * @default 30000
55
+ * @defaultValue 30000
56
56
  */
57
57
  stalledInterval?: number;
58
58
  /**
@@ -72,7 +72,7 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
72
72
  * perform stalled checkd and move jobs back to wait for jobs being processed
73
73
  * by this worker.
74
74
  *
75
- * @default false
75
+ * @defaultValue false
76
76
  */
77
77
  skipStalledCheck?: boolean;
78
78
  /**
@@ -80,13 +80,13 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
80
80
  * after lockDuration and moved back to the wait queue (if the stalled check is
81
81
  * not disabled)
82
82
  *
83
- * @default false
83
+ * @defaultValue false
84
84
  */
85
85
  skipLockRenewal?: boolean;
86
86
  /**
87
87
  * Number of seconds to long poll for jobs when the queue is empty.
88
88
  *
89
- * @default 5
89
+ * @defaultValue 5
90
90
  */
91
91
  drainDelay?: number;
92
92
  /**
@@ -95,7 +95,7 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
95
95
  * be picked up by the stalled checker and move back to wait so that another worker
96
96
  * can process it again.
97
97
  *
98
- * @default 30000
98
+ * @defaultValue 30000
99
99
  */
100
100
  lockDuration?: number;
101
101
  /**
@@ -108,7 +108,7 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
108
108
  /**
109
109
  * This is an internal option that should not be modified.
110
110
  *
111
- * @default 15000
111
+ * @defaultValue 15000
112
112
  */
113
113
  runRetryDelay?: number;
114
114
  /**
@@ -120,7 +120,7 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
120
120
  * Note: This option can only be used when specifying
121
121
  * a file for the processor argument.
122
122
  *
123
- * @default false
123
+ * @defaultValue false
124
124
  */
125
125
  useWorkerThreads?: boolean;
126
126
  /**
@@ -38,6 +38,7 @@ export * from './removeChildDependency-1';
38
38
  export * from './removeJob-3';
39
39
  export * from './removeJobScheduler-3';
40
40
  export * from './removeRepeatable-3';
41
+ export * from './removeUnprocessedChildren-2';
41
42
  export * from './reprocessJob-8';
42
43
  export * from './retryJob-11';
43
44
  export * from './saveStacktrace-1';
@@ -38,6 +38,7 @@ export * from './removeChildDependency-1';
38
38
  export * from './removeJob-3';
39
39
  export * from './removeJobScheduler-3';
40
40
  export * from './removeRepeatable-3';
41
+ export * from './removeUnprocessedChildren-2';
41
42
  export * from './reprocessJob-8';
42
43
  export * from './retryJob-11';
43
44
  export * from './saveStacktrace-1';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,C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Ac,+BAA+B,CAAC"}
@@ -1,38 +1,18 @@
1
1
  const content = `--[[
2
- Remove a job from all the queues it may be in as well as all its data.
2
+ Remove a job from all the statuses it may be in as well as all its data.
3
3
  In order to be able to remove a job, it cannot be active.
4
4
  Input:
5
- KEYS[1] queue prefix
5
+ KEYS[1] jobKey
6
6
  KEYS[2] meta key
7
7
  KEYS[3] repeat key
8
8
  ARGV[1] jobId
9
9
  ARGV[2] remove children
10
+ ARGV[3] queue prefix
10
11
  Events:
11
12
  'removed'
12
13
  ]]
13
14
  local rcall = redis.call
14
15
  -- Includes
15
- --[[
16
- Functions to destructure job key.
17
- Just a bit of warning, these functions may be a bit slow and affect performance significantly.
18
- ]]
19
- local getJobIdFromKey = function (jobKey)
20
- return string.match(jobKey, ".*:(.*)")
21
- end
22
- local getJobKeyPrefix = function (jobKey, jobId)
23
- return string.sub(jobKey, 0, #jobKey - #jobId)
24
- end
25
- --[[
26
- Function to get max events value or set by default 10000.
27
- ]]
28
- local function getOrSetMaxEvents(metaKey)
29
- local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
30
- if not maxEvents then
31
- maxEvents = 10000
32
- rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
33
- end
34
- return maxEvents
35
- end
36
16
  --[[
37
17
  Function to check if the job belongs to a job scheduler and
38
18
  current delayed job matches with jobId
@@ -54,6 +34,16 @@ end
54
34
  returns:
55
35
  boolean
56
36
  ]]
37
+ --[[
38
+ Functions to destructure job key.
39
+ Just a bit of warning, these functions may be a bit slow and affect performance significantly.
40
+ ]]
41
+ local getJobIdFromKey = function (jobKey)
42
+ return string.match(jobKey, ".*:(.*)")
43
+ end
44
+ local getJobKeyPrefix = function (jobKey, jobId)
45
+ return string.sub(jobKey, 0, #jobKey - #jobId)
46
+ end
57
47
  local function isLocked( prefix, jobId, removeChildren)
58
48
  local jobKey = prefix .. jobId;
59
49
  -- Check if this job is locked
@@ -78,6 +68,25 @@ local function isLocked( prefix, jobId, removeChildren)
78
68
  end
79
69
  return true
80
70
  end
71
+ --[[
72
+ Remove a job from all the statuses it may be in as well as all its data,
73
+ including its children. Active children can be ignored.
74
+ Events:
75
+ 'removed'
76
+ ]]
77
+ local rcall = redis.call
78
+ -- Includes
79
+ --[[
80
+ Function to get max events value or set by default 10000.
81
+ ]]
82
+ local function getOrSetMaxEvents(metaKey)
83
+ local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
84
+ if not maxEvents then
85
+ maxEvents = 10000
86
+ rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
87
+ end
88
+ return maxEvents
89
+ end
81
90
  --[[
82
91
  Function to remove deduplication key.
83
92
  ]]
@@ -241,66 +250,85 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
241
250
  end
242
251
  return false
243
252
  end
244
- local function removeJob(prefix, jobId, parentKey, removeChildren)
245
- local jobKey = prefix .. jobId;
246
- removeParentDependencyKey(jobKey, false, parentKey, nil)
247
- if removeChildren == "1" then
248
- -- Check if this job has children
249
- -- If so, we are going to try to remove the children recursively in deep first way because
250
- -- if some job is locked we must exit with and error.
251
- -- local countProcessed = rcall("HLEN", jobKey .. ":processed")
253
+ local removeJobChildren
254
+ local removeJobWithChildren
255
+ removeJobChildren = function(prefix, meta, jobKey, options)
256
+ -- Check if this job has children
257
+ -- If so, we are going to try to remove the children recursively in a depth-first way
258
+ -- because if some job is locked, we must exit with an error.
259
+ if not options.ignoreProcessed then
252
260
  local processed = rcall("HGETALL", jobKey .. ":processed")
253
- if (#processed > 0) then
261
+ if #processed > 0 then
254
262
  for i = 1, #processed, 2 do
255
263
  local childJobId = getJobIdFromKey(processed[i])
256
264
  local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
257
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
258
- end
259
- end
260
- local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
261
- if (#dependencies > 0) then
262
- for i, childJobKey in ipairs(dependencies) do
263
- -- We need to get the jobId for this job.
264
- local childJobId = getJobIdFromKey(childJobKey)
265
- local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
266
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
265
+ removeJobWithChildren(childJobPrefix, meta, childJobId, jobKey, options)
267
266
  end
268
267
  end
269
268
  local failed = rcall("HGETALL", jobKey .. ":failed")
270
- if (#failed > 0) then
269
+ if #failed > 0 then
271
270
  for i = 1, #failed, 2 do
272
271
  local childJobId = getJobIdFromKey(failed[i])
273
272
  local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)
274
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
273
+ removeJobWithChildren(childJobPrefix, meta, childJobId, jobKey, options)
275
274
  end
276
275
  end
277
276
  local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)
278
- if (#unsuccessful > 0) then
277
+ if #unsuccessful > 0 then
279
278
  for i = 1, #unsuccessful, 1 do
280
279
  local childJobId = getJobIdFromKey(unsuccessful[i])
281
280
  local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)
282
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
281
+ removeJobWithChildren(childJobPrefix, meta, childJobId, jobKey, options)
283
282
  end
284
283
  end
285
284
  end
286
- local prev = removeJobFromAnyState(prefix, jobId)
287
- removeDeduplicationKey(prefix, jobKey)
288
- if removeJobKeys(jobKey) > 0 then
289
- local maxEvents = getOrSetMaxEvents(KEYS[2])
290
- rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",
291
- prev)
285
+ local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
286
+ if #dependencies > 0 then
287
+ for i, childJobKey in ipairs(dependencies) do
288
+ local childJobId = getJobIdFromKey(childJobKey)
289
+ local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
290
+ removeJobWithChildren(childJobPrefix, meta, childJobId, jobKey, options)
291
+ end
292
+ end
293
+ end
294
+ removeJobWithChildren = function(prefix, meta, jobId, parentKey, options)
295
+ local jobKey = prefix .. jobId
296
+ if options.ignoreLocked then
297
+ if isLocked(prefix, jobId) then
298
+ return
299
+ end
300
+ end
301
+ -- Check if job is in the failed zset
302
+ local failedSet = prefix .. "failed"
303
+ if not (options.ignoreProcessed and rcall("ZSCORE", failedSet, jobId)) then
304
+ removeParentDependencyKey(jobKey, false, parentKey, nil)
305
+ if options.removeChildren then
306
+ removeJobChildren(prefix, meta, jobKey, options)
307
+ end
308
+ local prev = removeJobFromAnyState(prefix, jobId)
309
+ removeDeduplicationKey(prefix, jobKey)
310
+ if removeJobKeys(jobKey) > 0 then
311
+ local maxEvents = getOrSetMaxEvents(meta)
312
+ rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev", prev)
313
+ end
292
314
  end
293
315
  end
294
- local prefix = KEYS[1]
295
316
  local jobId = ARGV[1]
296
317
  local shouldRemoveChildren = ARGV[2]
297
- local jobKey = prefix .. jobId
318
+ local prefix = ARGV[3]
319
+ local jobKey = KEYS[1]
320
+ local meta = KEYS[2]
298
321
  local repeatKey = KEYS[3]
299
322
  if isJobSchedulerJob(jobId, jobKey, repeatKey) then
300
323
  return -8
301
324
  end
302
325
  if not isLocked(prefix, jobId, shouldRemoveChildren) then
303
- removeJob(prefix, jobId, nil, shouldRemoveChildren)
326
+ local options = {
327
+ removeChildren = shouldRemoveChildren == "1",
328
+ ignoreProcessed = false,
329
+ ignoreLocked = false
330
+ }
331
+ removeJobWithChildren(prefix, meta, jobId, nil, options)
304
332
  return 1
305
333
  end
306
334
  return 0
@@ -1 +1 @@
1
- {"version":3,"file":"removeJob-3.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkTf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeJob-3.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Uf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const removeUnprocessedChildren: {
2
+ name: string;
3
+ content: string;
4
+ keys: number;
5
+ };