bullmq 5.80.2 → 5.80.4

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.
@@ -115,6 +115,9 @@ class FlowProducer extends events_1.EventEmitter {
115
115
  if (typeof jobId === 'string') {
116
116
  jobsTree.job.id = jobId;
117
117
  }
118
+ else if (typeof jobId === 'number') {
119
+ jobsTree.job.id = jobId.toString();
120
+ }
118
121
  }
119
122
  return jobsTree;
120
123
  });
@@ -144,9 +147,8 @@ class FlowProducer extends events_1.EventEmitter {
144
147
  * Whenever the children of a given parent are completed, the parent
145
148
  * will be processed, being able to access the children's result data.
146
149
  *
147
- * All Jobs can be in different queues, either children or parents,
148
- * however this call would be atomic, either it fails and no jobs will
149
- * be added to the queues, or it succeeds and all jobs will be added.
150
+ * All Jobs can be in different queues, either children or parents.
151
+ * If a flow fails to be added, other flows in the batch may still be added.
150
152
  *
151
153
  * @param flows - an array of objects with a tree-like structure where children jobs
152
154
  * will be processed before their parents.
@@ -158,6 +160,7 @@ class FlowProducer extends events_1.EventEmitter {
158
160
  const client = await this.connection.client;
159
161
  const multi = client.multi();
160
162
  return (0, utils_1.trace)(this.telemetry, enums_1.SpanKind.PRODUCER, '', 'addBulkFlows', '', async (span) => {
163
+ var _a, _b;
161
164
  span === null || span === void 0 ? void 0 : span.setAttributes({
162
165
  [enums_1.TelemetryAttributes.BulkCount]: flows.length,
163
166
  [enums_1.TelemetryAttributes.BulkNames]: flows
@@ -172,9 +175,18 @@ class FlowProducer extends events_1.EventEmitter {
172
175
  continue;
173
176
  }
174
177
  const [err, jobId] = result;
175
- if (!err && typeof jobId === 'string') {
178
+ if (err) {
179
+ throw err;
180
+ }
181
+ if (typeof jobId === 'number' && jobId < 0) {
182
+ throw this.toFlowError(jobId, (0, utils_1.getParentKey)((_b = (_a = flows[index]) === null || _a === void 0 ? void 0 : _a.opts) === null || _b === void 0 ? void 0 : _b.parent));
183
+ }
184
+ if (typeof jobId === 'string') {
176
185
  jobsTrees[index].job.id = jobId;
177
186
  }
187
+ else if (typeof jobId === 'number') {
188
+ jobsTrees[index].job.id = jobId.toString();
189
+ }
178
190
  }
179
191
  return jobsTrees;
180
192
  });
@@ -76,7 +76,7 @@ local parentDependenciesKey = args[6]
76
76
  local timestamp = args[4]
77
77
 
78
78
  if args[2] == "" then
79
- jobId = jobCounter
79
+ jobId = jobCounter .. "" -- convert to string
80
80
  jobIdKey = args[1] .. jobId
81
81
  else
82
82
  jobId = args[2]
@@ -105,4 +105,4 @@ if parentDependenciesKey ~= nil then
105
105
  rcall("SADD", parentDependenciesKey, jobIdKey)
106
106
  end
107
107
 
108
- return jobId .. "" -- convert to string
108
+ return jobId
@@ -71,7 +71,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
71
71
  local parentDependenciesKey = args[6]
72
72
  local timestamp = args[4]
73
73
  if args[2] == "" then
74
- jobId = jobCounter
74
+ jobId = jobCounter .. "" -- convert to string
75
75
  jobIdKey = args[1] .. jobId
76
76
  else
77
77
  jobId = args[2]
@@ -107,4 +107,4 @@ if parentDependenciesKey ~= nil then
107
107
  rcall("SADD", parentDependenciesKey, jobIdKey)
108
108
  end
109
109
 
110
- return jobId .. "" -- convert to string
110
+ return jobId
@@ -78,7 +78,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
78
78
  local parentDependenciesKey = args[6]
79
79
  local timestamp = args[4]
80
80
  if args[2] == "" then
81
- jobId = jobCounter
81
+ jobId = jobCounter .. "" -- convert to string
82
82
  jobIdKey = args[1] .. jobId
83
83
  else
84
84
  jobId = args[2]
@@ -115,4 +115,4 @@ if parentDependenciesKey ~= nil then
115
115
  rcall("SADD", parentDependenciesKey, jobIdKey)
116
116
  end
117
117
 
118
- return jobId .. "" -- convert to string
118
+ return jobId
@@ -82,7 +82,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
82
82
  local parentDependenciesKey = args[6]
83
83
  local timestamp = args[4]
84
84
  if args[2] == "" then
85
- jobId = jobCounter
85
+ jobId = jobCounter .. "" -- convert to string
86
86
  jobIdKey = args[1] .. jobId
87
87
  else
88
88
  jobId = args[2]
@@ -120,4 +120,4 @@ if parentDependenciesKey ~= nil then
120
120
  rcall("SADD", parentDependenciesKey, jobIdKey)
121
121
  end
122
122
 
123
- return jobId .. "" -- convert to string
123
+ return jobId
@@ -546,7 +546,7 @@ local opts = cmsgpack.unpack(ARGV[3])
546
546
  local parentDependenciesKey = args[6]
547
547
  local timestamp = args[4]
548
548
  if args[2] == "" then
549
- jobId = jobCounter
549
+ jobId = jobCounter .. "" -- convert to string
550
550
  jobIdKey = args[1] .. jobId
551
551
  else
552
552
  jobId = args[2]
@@ -570,7 +570,7 @@ addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, KEYS[1], delay
570
570
  if parentDependenciesKey ~= nil then
571
571
  rcall("SADD", parentDependenciesKey, jobIdKey)
572
572
  end
573
- return jobId .. "" -- convert to string
573
+ return jobId
574
574
  `;
575
575
  exports.addDelayedJob = {
576
576
  name: 'addDelayedJob',
@@ -436,7 +436,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
436
436
  local parentDependenciesKey = args[6]
437
437
  local timestamp = args[4]
438
438
  if args[2] == "" then
439
- jobId = jobCounter
439
+ jobId = jobCounter .. "" -- convert to string
440
440
  jobIdKey = args[1] .. jobId
441
441
  else
442
442
  jobId = args[2]
@@ -467,7 +467,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
467
467
  if parentDependenciesKey ~= nil then
468
468
  rcall("SADD", parentDependenciesKey, jobIdKey)
469
469
  end
470
- return jobId .. "" -- convert to string
470
+ return jobId
471
471
  `;
472
472
  exports.addParentJob = {
473
473
  name: 'addParentJob',
@@ -509,7 +509,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
509
509
  local parentDependenciesKey = args[6]
510
510
  local timestamp = args[4]
511
511
  if args[2] == "" then
512
- jobId = jobCounter
512
+ jobId = jobCounter .. "" -- convert to string
513
513
  jobIdKey = args[1] .. jobId
514
514
  else
515
515
  jobId = args[2]
@@ -540,7 +540,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
540
540
  if parentDependenciesKey ~= nil then
541
541
  rcall("SADD", parentDependenciesKey, jobIdKey)
542
542
  end
543
- return jobId .. "" -- convert to string
543
+ return jobId
544
544
  `;
545
545
  exports.addPrioritizedJob = {
546
546
  name: 'addPrioritizedJob',
@@ -513,7 +513,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
513
513
  local parentDependenciesKey = args[6]
514
514
  local timestamp = args[4]
515
515
  if args[2] == "" then
516
- jobId = jobCounter
516
+ jobId = jobCounter .. "" -- convert to string
517
517
  jobIdKey = args[1] .. jobId
518
518
  else
519
519
  jobId = args[2]
@@ -544,7 +544,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
544
544
  if parentDependenciesKey ~= nil then
545
545
  rcall("SADD", parentDependenciesKey, jobIdKey)
546
546
  end
547
- return jobId .. "" -- convert to string
547
+ return jobId
548
548
  `;
549
549
  exports.addStandardJob = {
550
550
  name: 'addStandardJob',