@tachybase/plugin-adapter-bullmq 1.3.17 → 1.3.18

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 (347) hide show
  1. package/dist/externalVersion.js +2 -2
  2. package/dist/node_modules/@bull-board/api/dist/src/handlers/error.d.ts +4 -2
  3. package/dist/node_modules/@bull-board/api/dist/src/handlers/error.js +2 -2
  4. package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.d.ts +4 -0
  5. package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.js +15 -0
  6. package/dist/node_modules/@bull-board/api/dist/src/handlers/queues.js +4 -0
  7. package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.d.ts +4 -0
  8. package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.js +15 -0
  9. package/dist/node_modules/@bull-board/api/dist/src/index.js +1 -1
  10. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.d.ts +4 -0
  11. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.js +6 -0
  12. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bull.js +6 -4
  13. package/dist/node_modules/@bull-board/api/dist/src/routes.js +4 -0
  14. package/dist/node_modules/@bull-board/api/dist/typings/app.d.ts +22 -2
  15. package/dist/node_modules/@bull-board/api/package.json +1 -1
  16. package/dist/node_modules/@bull-board/koa/dist/KoaAdapter.js +1 -1
  17. package/dist/node_modules/@bull-board/koa/dist/index.js +101 -101
  18. package/dist/node_modules/@bull-board/koa/package.json +1 -1
  19. package/dist/node_modules/bullmq/dist/cjs/classes/backoffs.js +18 -5
  20. package/dist/node_modules/bullmq/dist/cjs/classes/child-pool.js +7 -2
  21. package/dist/node_modules/bullmq/dist/cjs/classes/child-processor.js +59 -5
  22. package/dist/node_modules/bullmq/dist/cjs/classes/child.js +3 -1
  23. package/dist/node_modules/bullmq/dist/cjs/classes/errors/index.js +2 -1
  24. package/dist/node_modules/bullmq/dist/cjs/classes/errors/waiting-error.js +19 -0
  25. package/dist/node_modules/bullmq/dist/cjs/classes/flow-producer.js +21 -5
  26. package/dist/node_modules/bullmq/dist/cjs/classes/index.js +1 -0
  27. package/dist/node_modules/bullmq/dist/cjs/classes/job-scheduler.js +88 -62
  28. package/dist/node_modules/bullmq/dist/cjs/classes/job.js +216 -109
  29. package/dist/node_modules/bullmq/dist/cjs/classes/main-base.js +1 -1
  30. package/dist/node_modules/bullmq/dist/cjs/classes/queue-base.js +10 -9
  31. package/dist/node_modules/bullmq/dist/cjs/classes/queue-getters.js +34 -14
  32. package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +19 -13
  33. package/dist/node_modules/bullmq/dist/cjs/classes/redis-connection.js +16 -9
  34. package/dist/node_modules/bullmq/dist/cjs/classes/repeat.js +1 -1
  35. package/dist/node_modules/bullmq/dist/cjs/classes/sandbox.js +54 -28
  36. package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +141 -39
  37. package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +191 -182
  38. package/dist/node_modules/bullmq/dist/cjs/commands/addDelayedJob-6.lua +6 -17
  39. package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-11.lua +123 -0
  40. package/dist/node_modules/bullmq/dist/{esm/commands/addParentJob-4.lua → cjs/commands/addParentJob-5.lua} +7 -6
  41. package/dist/node_modules/bullmq/dist/cjs/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
  42. package/dist/node_modules/bullmq/dist/cjs/commands/addRepeatableJob-2.lua +2 -2
  43. package/dist/node_modules/bullmq/dist/{esm/commands/addStandardJob-8.lua → cjs/commands/addStandardJob-9.lua} +9 -8
  44. package/dist/node_modules/bullmq/dist/cjs/commands/cleanJobsInSet-3.lua +9 -5
  45. package/dist/node_modules/bullmq/dist/cjs/commands/drain-5.lua +16 -16
  46. package/dist/node_modules/bullmq/dist/cjs/commands/getDependencyCounts-4.lua +31 -0
  47. package/dist/node_modules/bullmq/dist/cjs/commands/getState-8.lua +5 -5
  48. package/dist/node_modules/bullmq/dist/cjs/commands/getStateV2-8.lua +8 -8
  49. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addDelayedJob.lua +23 -0
  50. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobFromScheduler.lua +37 -0
  51. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobWithPriority.lua +2 -2
  52. package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanList.lua +4 -2
  53. package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanSet.lua +3 -11
  54. package/dist/node_modules/bullmq/dist/cjs/commands/includes/collectMetrics.lua +1 -1
  55. package/dist/node_modules/bullmq/dist/cjs/commands/includes/deduplicateJob.lua +63 -18
  56. package/dist/node_modules/bullmq/dist/cjs/commands/includes/filterOutJobsToIgnore.lua +14 -0
  57. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +1 -1
  58. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getOrSetMaxEvents.lua +6 -6
  59. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getPriorityScore.lua +8 -0
  60. package/dist/node_modules/bullmq/dist/cjs/commands/includes/isJobSchedulerJob.lua +15 -0
  61. package/dist/node_modules/bullmq/dist/cjs/commands/includes/isLocked.lua +1 -0
  62. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
  63. package/dist/node_modules/bullmq/dist/cjs/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
  64. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWait.lua +45 -0
  65. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  66. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  67. package/dist/node_modules/bullmq/dist/cjs/commands/includes/prepareJobForProcessing.lua +2 -1
  68. package/dist/node_modules/bullmq/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -3
  69. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  70. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  71. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJob.lua +2 -2
  72. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
  73. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobWithChildren.lua +95 -0
  74. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeListJobs.lua +7 -1
  75. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
  76. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeZSetJobs.lua +2 -8
  77. package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJob.lua +2 -2
  78. package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJobScheduler.lua +52 -0
  79. package/dist/node_modules/bullmq/dist/cjs/commands/includes/trimEvents.lua +1 -1
  80. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateExistingJobsParent.lua +1 -1
  81. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateJobFields.lua +5 -5
  82. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  83. package/dist/node_modules/bullmq/dist/cjs/commands/isFinished-3.lua +2 -2
  84. package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-9.lua +63 -0
  85. package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-8.lua +109 -0
  86. package/dist/node_modules/bullmq/dist/cjs/commands/moveToActive-11.lua +3 -2
  87. package/dist/node_modules/bullmq/dist/cjs/commands/moveToFinished-14.lua +52 -52
  88. package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-8.lua +106 -0
  89. package/dist/node_modules/bullmq/dist/cjs/commands/removeJob-2.lua +18 -66
  90. package/dist/node_modules/bullmq/dist/cjs/commands/removeJobScheduler-3.lua +1 -1
  91. package/dist/node_modules/bullmq/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
  92. package/dist/node_modules/bullmq/dist/cjs/commands/retryJob-11.lua +11 -5
  93. package/dist/node_modules/bullmq/dist/cjs/commands/updateJobScheduler-12.lua +90 -0
  94. package/dist/node_modules/bullmq/dist/cjs/commands/updateRepeatableJobMillis-1.lua +1 -1
  95. package/dist/node_modules/bullmq/dist/cjs/enums/child-command.js +2 -0
  96. package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +2 -1
  97. package/dist/node_modules/bullmq/dist/cjs/enums/parent-command.js +5 -2
  98. package/dist/node_modules/bullmq/dist/cjs/index.js +1 -1
  99. package/dist/node_modules/bullmq/dist/cjs/interfaces/index.js +2 -1
  100. package/dist/node_modules/bullmq/dist/cjs/interfaces/{debounce-options.js → parent-options.js} +1 -1
  101. package/dist/node_modules/bullmq/dist/cjs/interfaces/receiver.js +3 -0
  102. package/dist/node_modules/bullmq/dist/cjs/scripts/addDelayedJob-6.js +163 -84
  103. package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-11.js +465 -0
  104. package/dist/node_modules/bullmq/dist/cjs/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
  105. package/dist/node_modules/bullmq/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
  106. package/dist/node_modules/bullmq/dist/cjs/scripts/addRepeatableJob-2.js +18 -13
  107. package/dist/node_modules/bullmq/dist/cjs/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
  108. package/dist/node_modules/bullmq/dist/cjs/scripts/changeDelay-4.js +7 -7
  109. package/dist/node_modules/bullmq/dist/cjs/scripts/changePriority-7.js +8 -2
  110. package/dist/node_modules/bullmq/dist/cjs/scripts/cleanJobsInSet-3.js +45 -29
  111. package/dist/node_modules/bullmq/dist/cjs/scripts/drain-5.js +49 -35
  112. package/dist/node_modules/bullmq/dist/cjs/scripts/getDependencyCounts-4.js +37 -0
  113. package/dist/node_modules/bullmq/dist/cjs/scripts/getState-8.js +5 -5
  114. package/dist/node_modules/bullmq/dist/cjs/scripts/getStateV2-8.js +8 -8
  115. package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +10 -7
  116. package/dist/node_modules/bullmq/dist/cjs/scripts/isFinished-3.js +2 -2
  117. package/dist/node_modules/bullmq/dist/cjs/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
  118. package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobsToWait-8.js +6 -6
  119. package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-8.js +171 -0
  120. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToActive-11.js +18 -8
  121. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToDelayed-8.js +12 -12
  122. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToFinished-14.js +218 -155
  123. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-8.js +529 -0
  124. package/dist/node_modules/bullmq/dist/cjs/scripts/obliterate-2.js +33 -20
  125. package/dist/node_modules/bullmq/dist/cjs/scripts/pause-7.js +1 -1
  126. package/dist/node_modules/bullmq/dist/cjs/scripts/promote-9.js +8 -2
  127. package/dist/node_modules/bullmq/dist/cjs/scripts/removeChildDependency-1.js +7 -7
  128. package/dist/node_modules/bullmq/dist/cjs/scripts/removeJob-2.js +120 -63
  129. package/dist/node_modules/bullmq/dist/cjs/scripts/removeJobScheduler-3.js +3 -3
  130. package/dist/node_modules/bullmq/dist/cjs/scripts/removeRepeatable-3.js +2 -2
  131. package/dist/node_modules/bullmq/dist/cjs/scripts/removeUnprocessedChildren-2.js +339 -0
  132. package/dist/node_modules/bullmq/dist/cjs/scripts/reprocessJob-8.js +6 -6
  133. package/dist/node_modules/bullmq/dist/cjs/scripts/retryJob-11.js +47 -26
  134. package/dist/node_modules/bullmq/dist/cjs/scripts/updateJobScheduler-12.js +274 -0
  135. package/dist/node_modules/bullmq/dist/cjs/scripts/updateProgress-3.js +6 -6
  136. package/dist/node_modules/bullmq/dist/cjs/scripts/updateRepeatableJobMillis-1.js +1 -1
  137. package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  138. package/dist/node_modules/bullmq/dist/cjs/types/deduplication-options.js +3 -0
  139. package/dist/node_modules/bullmq/dist/cjs/types/index.js +3 -0
  140. package/dist/node_modules/bullmq/dist/cjs/types/job-progress.js +3 -0
  141. package/dist/node_modules/bullmq/dist/cjs/types/script-queue-context.js +3 -0
  142. package/dist/node_modules/bullmq/dist/cjs/utils.js +29 -1
  143. package/dist/node_modules/bullmq/dist/cjs/version.js +1 -1
  144. package/dist/node_modules/bullmq/dist/esm/classes/backoffs.d.ts +1 -1
  145. package/dist/node_modules/bullmq/dist/esm/classes/backoffs.js +18 -5
  146. package/dist/node_modules/bullmq/dist/esm/classes/child-pool.d.ts +1 -1
  147. package/dist/node_modules/bullmq/dist/esm/classes/child-pool.js +7 -2
  148. package/dist/node_modules/bullmq/dist/esm/classes/child-processor.d.ts +3 -2
  149. package/dist/node_modules/bullmq/dist/esm/classes/child-processor.js +59 -5
  150. package/dist/node_modules/bullmq/dist/esm/classes/child.js +3 -1
  151. package/dist/node_modules/bullmq/dist/esm/classes/errors/index.d.ts +2 -1
  152. package/dist/node_modules/bullmq/dist/esm/classes/errors/index.js +2 -1
  153. package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.d.ts +10 -0
  154. package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.js +15 -0
  155. package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.d.ts +3 -9
  156. package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.js +21 -5
  157. package/dist/node_modules/bullmq/dist/esm/classes/index.d.ts +1 -0
  158. package/dist/node_modules/bullmq/dist/esm/classes/index.js +1 -0
  159. package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.d.ts +2 -2
  160. package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.js +88 -62
  161. package/dist/node_modules/bullmq/dist/esm/classes/job.d.ts +69 -19
  162. package/dist/node_modules/bullmq/dist/esm/classes/job.js +217 -110
  163. package/dist/node_modules/bullmq/dist/esm/classes/main-base.d.ts +2 -3
  164. package/dist/node_modules/bullmq/dist/esm/classes/main-base.js +1 -1
  165. package/dist/node_modules/bullmq/dist/esm/classes/queue-base.d.ts +2 -5
  166. package/dist/node_modules/bullmq/dist/esm/classes/queue-base.js +11 -10
  167. package/dist/node_modules/bullmq/dist/esm/classes/queue-events-producer.d.ts +2 -2
  168. package/dist/node_modules/bullmq/dist/esm/classes/queue-events.d.ts +118 -29
  169. package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.d.ts +20 -13
  170. package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.js +34 -14
  171. package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +19 -16
  172. package/dist/node_modules/bullmq/dist/esm/classes/queue.js +19 -13
  173. package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.d.ts +7 -3
  174. package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.js +16 -9
  175. package/dist/node_modules/bullmq/dist/esm/classes/repeat.js +1 -1
  176. package/dist/node_modules/bullmq/dist/esm/classes/sandbox.js +54 -28
  177. package/dist/node_modules/bullmq/dist/esm/classes/scripts.d.ts +20 -13
  178. package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +141 -39
  179. package/dist/node_modules/bullmq/dist/esm/classes/worker.d.ts +28 -7
  180. package/dist/node_modules/bullmq/dist/esm/classes/worker.js +192 -183
  181. package/dist/node_modules/bullmq/dist/esm/commands/addDelayedJob-6.lua +6 -17
  182. package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-11.lua +123 -0
  183. package/dist/node_modules/bullmq/dist/{cjs/commands/addParentJob-4.lua → esm/commands/addParentJob-5.lua} +7 -6
  184. package/dist/node_modules/bullmq/dist/esm/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
  185. package/dist/node_modules/bullmq/dist/esm/commands/addRepeatableJob-2.lua +2 -2
  186. package/dist/node_modules/bullmq/dist/{cjs/commands/addStandardJob-8.lua → esm/commands/addStandardJob-9.lua} +9 -8
  187. package/dist/node_modules/bullmq/dist/esm/commands/cleanJobsInSet-3.lua +9 -5
  188. package/dist/node_modules/bullmq/dist/esm/commands/drain-5.lua +16 -16
  189. package/dist/node_modules/bullmq/dist/esm/commands/getDependencyCounts-4.lua +31 -0
  190. package/dist/node_modules/bullmq/dist/esm/commands/getState-8.lua +5 -5
  191. package/dist/node_modules/bullmq/dist/esm/commands/getStateV2-8.lua +8 -8
  192. package/dist/node_modules/bullmq/dist/esm/commands/includes/addDelayedJob.lua +23 -0
  193. package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobFromScheduler.lua +37 -0
  194. package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobWithPriority.lua +2 -2
  195. package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanList.lua +4 -2
  196. package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanSet.lua +3 -11
  197. package/dist/node_modules/bullmq/dist/esm/commands/includes/collectMetrics.lua +1 -1
  198. package/dist/node_modules/bullmq/dist/esm/commands/includes/deduplicateJob.lua +63 -18
  199. package/dist/node_modules/bullmq/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
  200. package/dist/node_modules/bullmq/dist/esm/commands/includes/getNextDelayedTimestamp.lua +1 -1
  201. package/dist/node_modules/bullmq/dist/esm/commands/includes/getOrSetMaxEvents.lua +6 -6
  202. package/dist/node_modules/bullmq/dist/esm/commands/includes/getPriorityScore.lua +8 -0
  203. package/dist/node_modules/bullmq/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
  204. package/dist/node_modules/bullmq/dist/esm/commands/includes/isLocked.lua +1 -0
  205. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
  206. package/dist/node_modules/bullmq/dist/esm/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
  207. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWait.lua +45 -0
  208. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  209. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  210. package/dist/node_modules/bullmq/dist/esm/commands/includes/prepareJobForProcessing.lua +2 -1
  211. package/dist/node_modules/bullmq/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -3
  212. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  213. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  214. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJob.lua +2 -2
  215. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobKeys.lua +2 -2
  216. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobWithChildren.lua +95 -0
  217. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeListJobs.lua +7 -1
  218. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
  219. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
  220. package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJob.lua +2 -2
  221. package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJobScheduler.lua +52 -0
  222. package/dist/node_modules/bullmq/dist/esm/commands/includes/trimEvents.lua +1 -1
  223. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateExistingJobsParent.lua +1 -1
  224. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateJobFields.lua +5 -5
  225. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  226. package/dist/node_modules/bullmq/dist/esm/commands/isFinished-3.lua +2 -2
  227. package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-9.lua +63 -0
  228. package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-8.lua +109 -0
  229. package/dist/node_modules/bullmq/dist/esm/commands/moveToActive-11.lua +3 -2
  230. package/dist/node_modules/bullmq/dist/esm/commands/moveToFinished-14.lua +52 -52
  231. package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-8.lua +106 -0
  232. package/dist/node_modules/bullmq/dist/esm/commands/removeJob-2.lua +18 -66
  233. package/dist/node_modules/bullmq/dist/esm/commands/removeJobScheduler-3.lua +1 -1
  234. package/dist/node_modules/bullmq/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
  235. package/dist/node_modules/bullmq/dist/esm/commands/retryJob-11.lua +11 -5
  236. package/dist/node_modules/bullmq/dist/esm/commands/updateJobScheduler-12.lua +90 -0
  237. package/dist/node_modules/bullmq/dist/esm/commands/updateRepeatableJobMillis-1.lua +1 -1
  238. package/dist/node_modules/bullmq/dist/esm/enums/child-command.d.ts +3 -1
  239. package/dist/node_modules/bullmq/dist/esm/enums/child-command.js +2 -0
  240. package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +3 -2
  241. package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +2 -1
  242. package/dist/node_modules/bullmq/dist/esm/enums/parent-command.d.ts +5 -2
  243. package/dist/node_modules/bullmq/dist/esm/enums/parent-command.js +5 -2
  244. package/dist/node_modules/bullmq/dist/esm/interfaces/backoff-options.d.ts +5 -0
  245. package/dist/node_modules/bullmq/dist/esm/interfaces/base-job-options.d.ts +3 -9
  246. package/dist/node_modules/bullmq/dist/esm/interfaces/child-message.d.ts +1 -0
  247. package/dist/node_modules/bullmq/dist/esm/interfaces/index.d.ts +2 -1
  248. package/dist/node_modules/bullmq/dist/esm/interfaces/index.js +2 -1
  249. package/dist/node_modules/bullmq/dist/esm/interfaces/job-json.d.ts +6 -2
  250. package/dist/node_modules/bullmq/dist/esm/interfaces/job-scheduler-json.d.ts +7 -4
  251. package/dist/node_modules/bullmq/dist/esm/interfaces/minimal-job.d.ts +34 -15
  252. package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.d.ts +11 -0
  253. package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.js +2 -0
  254. package/dist/node_modules/bullmq/dist/esm/interfaces/parent.d.ts +6 -2
  255. package/dist/node_modules/bullmq/dist/esm/interfaces/queue-options.d.ts +15 -6
  256. package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.d.ts +4 -0
  257. package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.js +2 -0
  258. package/dist/node_modules/bullmq/dist/esm/interfaces/repeat-options.d.ts +1 -2
  259. package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-options.d.ts +2 -0
  260. package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job.d.ts +3 -2
  261. package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
  262. package/dist/node_modules/bullmq/dist/esm/interfaces/telemetry.d.ts +18 -15
  263. package/dist/node_modules/bullmq/dist/esm/interfaces/worker-options.d.ts +10 -10
  264. package/dist/node_modules/bullmq/dist/esm/scripts/addDelayedJob-6.js +163 -84
  265. package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-11.js +462 -0
  266. package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
  267. package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
  268. package/dist/node_modules/bullmq/dist/esm/scripts/addRepeatableJob-2.js +18 -13
  269. package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
  270. package/dist/node_modules/bullmq/dist/esm/scripts/changeDelay-4.js +7 -7
  271. package/dist/node_modules/bullmq/dist/esm/scripts/changePriority-7.js +8 -2
  272. package/dist/node_modules/bullmq/dist/esm/scripts/cleanJobsInSet-3.js +45 -29
  273. package/dist/node_modules/bullmq/dist/esm/scripts/drain-5.js +49 -35
  274. package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.d.ts +5 -0
  275. package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.js +34 -0
  276. package/dist/node_modules/bullmq/dist/esm/scripts/getState-8.js +5 -5
  277. package/dist/node_modules/bullmq/dist/esm/scripts/getStateV2-8.js +8 -8
  278. package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +10 -7
  279. package/dist/node_modules/bullmq/dist/esm/scripts/index.js +10 -7
  280. package/dist/node_modules/bullmq/dist/esm/scripts/isFinished-3.js +2 -2
  281. package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
  282. package/dist/node_modules/bullmq/dist/esm/scripts/moveJobsToWait-8.js +6 -6
  283. package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-8.js +168 -0
  284. package/dist/node_modules/bullmq/dist/esm/scripts/moveToActive-11.js +18 -8
  285. package/dist/node_modules/bullmq/dist/esm/scripts/moveToDelayed-8.js +12 -12
  286. package/dist/node_modules/bullmq/dist/esm/scripts/moveToFinished-14.js +218 -155
  287. package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-8.js +526 -0
  288. package/dist/node_modules/bullmq/dist/esm/scripts/obliterate-2.js +33 -20
  289. package/dist/node_modules/bullmq/dist/esm/scripts/pause-7.js +1 -1
  290. package/dist/node_modules/bullmq/dist/esm/scripts/promote-9.js +8 -2
  291. package/dist/node_modules/bullmq/dist/esm/scripts/removeChildDependency-1.js +7 -7
  292. package/dist/node_modules/bullmq/dist/esm/scripts/removeJob-2.js +120 -63
  293. package/dist/node_modules/bullmq/dist/esm/scripts/removeJobScheduler-3.js +3 -3
  294. package/dist/node_modules/bullmq/dist/esm/scripts/removeRepeatable-3.js +2 -2
  295. package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
  296. package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.js +336 -0
  297. package/dist/node_modules/bullmq/dist/esm/scripts/reprocessJob-8.js +6 -6
  298. package/dist/node_modules/bullmq/dist/esm/scripts/retryJob-11.js +47 -26
  299. package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.d.ts +5 -0
  300. package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.js +271 -0
  301. package/dist/node_modules/bullmq/dist/esm/scripts/updateProgress-3.js +6 -6
  302. package/dist/node_modules/bullmq/dist/esm/scripts/updateRepeatableJobMillis-1.js +1 -1
  303. package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -1
  304. package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.d.ts +22 -0
  305. package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.js +2 -0
  306. package/dist/node_modules/bullmq/dist/esm/types/index.d.ts +3 -0
  307. package/dist/node_modules/bullmq/dist/esm/types/index.js +3 -0
  308. package/dist/node_modules/bullmq/dist/esm/types/job-options.d.ts +19 -8
  309. package/dist/node_modules/bullmq/dist/esm/types/job-progress.d.ts +1 -0
  310. package/dist/node_modules/bullmq/dist/esm/types/job-progress.js +2 -0
  311. package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.d.ts +2 -0
  312. package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.js +2 -0
  313. package/dist/node_modules/bullmq/dist/esm/utils.d.ts +25 -5
  314. package/dist/node_modules/bullmq/dist/esm/utils.js +27 -0
  315. package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -1
  316. package/dist/node_modules/bullmq/dist/esm/version.js +1 -1
  317. package/dist/node_modules/bullmq/package.json +1 -1
  318. package/package.json +7 -7
  319. package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-2.lua +0 -91
  320. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
  321. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
  322. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  323. package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-10.lua +0 -60
  324. package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -156
  325. package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
  326. package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-2.js +0 -237
  327. package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-9.js +0 -529
  328. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
  329. package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-2.lua +0 -91
  330. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
  331. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
  332. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  333. package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-10.lua +0 -60
  334. package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -156
  335. package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
  336. package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.d.ts +0 -13
  337. package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.js +0 -2
  338. package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-2.js +0 -234
  339. package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-9.js +0 -526
  340. package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
  341. /package/dist/node_modules/bullmq/dist/esm/scripts/{addJobScheduler-2.d.ts → addJobScheduler-11.d.ts} +0 -0
  342. /package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.d.ts → addParentJob-5.d.ts} +0 -0
  343. /package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-9.d.ts} +0 -0
  344. /package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.d.ts → addStandardJob-9.d.ts} +0 -0
  345. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.d.ts → moveJobFromActiveToWait-9.d.ts} +0 -0
  346. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveStalledJobsToWait-9.d.ts → moveStalledJobsToWait-8.d.ts} +0 -0
  347. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
@@ -1,21 +1,10 @@
1
1
  import { __rest } from "tslib";
2
2
  import { debuglog } from 'util';
3
- import { errorObject, isEmpty, getParentKey, lengthInUtf8Bytes, parseObjectValues, tryCatch, removeUndefinedFields, invertObject, } from '../utils';
3
+ import { createScripts, errorObject, isEmpty, getParentKey, lengthInUtf8Bytes, optsDecodeMap, optsEncodeMap, parseObjectValues, tryCatch, removeUndefinedFields, } from '../utils';
4
4
  import { Backoffs } from './backoffs';
5
- import { Scripts } from './scripts';
6
5
  import { UnrecoverableError } from './errors/unrecoverable-error';
7
6
  import { SpanKind } from '../enums';
8
7
  const logger = debuglog('bull');
9
- // Simple options decode map.
10
- const optsDecodeMap = {
11
- de: 'deduplication',
12
- fpof: 'failParentOnFailure',
13
- idof: 'ignoreDependencyOnFailure',
14
- kl: 'keepLogs',
15
- rdof: 'removeDependencyOnFailure',
16
- };
17
- const optsEncodeMap = Object.assign(Object.assign({}, invertObject(optsDecodeMap)), {
18
- /*/ Legacy for backwards compatibility */ debounce: 'de' });
19
8
  export const PRIORITY_LIMIT = 2 ** 21;
20
9
  /**
21
10
  * Job
@@ -25,7 +14,6 @@ export const PRIORITY_LIMIT = 2 ** 21;
25
14
  *
26
15
  * A Job instance is also passed to the Worker's process function.
27
16
  *
28
- * @class Job
29
17
  */
30
18
  export class Job {
31
19
  constructor(queue,
@@ -83,6 +71,11 @@ export class Job {
83
71
  * @defaultValue 0
84
72
  */
85
73
  this.attemptsMade = 0;
74
+ /**
75
+ * Number of times where job has stalled.
76
+ * @defaultValue 0
77
+ */
78
+ this.stalledCounter = 0;
86
79
  const _a = this.opts, { repeatJobKey } = _a, restOpts = __rest(_a, ["repeatJobKey"]);
87
80
  this.opts = Object.assign({
88
81
  attempts: 0,
@@ -93,15 +86,27 @@ export class Job {
93
86
  this.timestamp = opts.timestamp ? opts.timestamp : Date.now();
94
87
  this.opts.backoff = Backoffs.normalize(opts.backoff);
95
88
  this.parentKey = getParentKey(opts.parent);
96
- this.parent = opts.parent
97
- ? { id: opts.parent.id, queueKey: opts.parent.queue }
98
- : undefined;
89
+ if (opts.parent) {
90
+ this.parent = { id: opts.parent.id, queueKey: opts.parent.queue };
91
+ if (opts.failParentOnFailure) {
92
+ this.parent.fpof = true;
93
+ }
94
+ if (opts.removeDependencyOnFailure) {
95
+ this.parent.rdof = true;
96
+ }
97
+ if (opts.ignoreDependencyOnFailure) {
98
+ this.parent.idof = true;
99
+ }
100
+ if (opts.continueParentOnFailure) {
101
+ this.parent.cpof = true;
102
+ }
103
+ }
99
104
  this.debounceId = opts.debounce ? opts.debounce.id : undefined;
100
105
  this.deduplicationId = opts.deduplication
101
106
  ? opts.deduplication.id
102
107
  : this.debounceId;
103
108
  this.toKey = queue.toKey.bind(queue);
104
- this.setScripts();
109
+ this.createScripts();
105
110
  this.queueQualifiedName = queue.qualifiedName;
106
111
  }
107
112
  /**
@@ -167,6 +172,7 @@ export class Job {
167
172
  const job = new this(queue, json.name, data, opts, json.id || jobId);
168
173
  job.progress = JSON.parse(json.progress || '0');
169
174
  job.delay = parseInt(json.delay);
175
+ job.priority = parseInt(json.priority);
170
176
  job.timestamp = parseInt(json.timestamp);
171
177
  if (json.finishedOn) {
172
178
  job.finishedOn = parseInt(json.finishedOn);
@@ -181,9 +187,15 @@ export class Job {
181
187
  job.debounceId = json.deid;
182
188
  job.deduplicationId = json.deid;
183
189
  }
184
- job.failedReason = json.failedReason;
190
+ if (json.failedReason) {
191
+ job.failedReason = json.failedReason;
192
+ }
185
193
  job.attemptsStarted = parseInt(json.ats || '0');
186
194
  job.attemptsMade = parseInt(json.attemptsMade || json.atm || '0');
195
+ job.stalledCounter = parseInt(json.stc || '0');
196
+ if (json.defa) {
197
+ job.deferredFailure = json.defa;
198
+ }
187
199
  job.stacktrace = getTraces(json.stacktrace);
188
200
  if (typeof json.returnvalue === 'string') {
189
201
  job.returnvalue = getReturnValue(json.returnvalue);
@@ -202,17 +214,17 @@ export class Job {
202
214
  }
203
215
  return job;
204
216
  }
205
- setScripts() {
206
- this.scripts = new Scripts(this.queue);
217
+ createScripts() {
218
+ this.scripts = createScripts(this.queue);
207
219
  }
208
- static optsFromJSON(rawOpts) {
220
+ static optsFromJSON(rawOpts, optsDecode = optsDecodeMap) {
209
221
  const opts = JSON.parse(rawOpts || '{}');
210
222
  const optionEntries = Object.entries(opts);
211
223
  const options = {};
212
224
  for (const item of optionEntries) {
213
225
  const [attributeName, value] = item;
214
- if (optsDecodeMap[attributeName]) {
215
- options[optsDecodeMap[attributeName]] =
226
+ if (optsDecode[attributeName]) {
227
+ options[optsDecode[attributeName]] =
216
228
  value;
217
229
  }
218
230
  else {
@@ -249,10 +261,10 @@ export class Job {
249
261
  /**
250
262
  * addJobLog
251
263
  *
252
- * @param queue Queue instance
253
- * @param jobId Job id
254
- * @param logRow Log row
255
- * @param keepLogs optional maximum number of logs to keep
264
+ * @param queue - A minimal queue instance
265
+ * @param jobId - Job id
266
+ * @param logRow - String with a row of log data to be logged
267
+ * @param keepLogs - The optional amount of log entries to preserve
256
268
  *
257
269
  * @returns The total number of log entries for this job so far.
258
270
  */
@@ -279,6 +291,7 @@ export class Job {
279
291
  progress: this.progress,
280
292
  attemptsMade: this.attemptsMade,
281
293
  attemptsStarted: this.attemptsStarted,
294
+ stalledCounter: this.stalledCounter,
282
295
  finishedOn: this.finishedOn,
283
296
  processedOn: this.processedOn,
284
297
  timestamp: this.timestamp,
@@ -291,16 +304,16 @@ export class Job {
291
304
  nrjid: this.nextRepeatableJobId,
292
305
  });
293
306
  }
294
- static optsAsJSON(opts = {}) {
307
+ static optsAsJSON(opts = {}, optsEncode = optsEncodeMap) {
295
308
  const optionEntries = Object.entries(opts);
296
309
  const options = {};
297
310
  for (const [attributeName, value] of optionEntries) {
298
311
  if (typeof value === 'undefined') {
299
312
  continue;
300
313
  }
301
- if (attributeName in optsEncodeMap) {
314
+ if (attributeName in optsEncode) {
302
315
  const compressableAttribute = attributeName;
303
- const key = optsEncodeMap[compressableAttribute];
316
+ const key = optsEncode[compressableAttribute];
304
317
  options[key] = value;
305
318
  }
306
319
  else {
@@ -399,6 +412,18 @@ export class Job {
399
412
  throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`);
400
413
  }
401
414
  }
415
+ /**
416
+ * Remove all children from this job that are not yet processed,
417
+ * in other words that are in any other state than completed, failed or active.
418
+ *
419
+ * @remarks
420
+ * - Jobs with locks (most likely active) are ignored.
421
+ * - This method can be slow if the number of children is large (\> 1000).
422
+ */
423
+ async removeUnprocessedChildren() {
424
+ const jobId = this.id;
425
+ await this.scripts.removeUnprocessedChildren(jobId);
426
+ }
402
427
  /**
403
428
  * Extend the lock for this job.
404
429
  *
@@ -418,19 +443,35 @@ export class Job {
418
443
  * @returns Returns the jobData of the next job in the waiting queue or void.
419
444
  */
420
445
  async moveToCompleted(returnValue, token, fetchNext = true) {
421
- await this.queue.waitUntilReady();
422
- this.returnvalue = returnValue || void 0;
423
- const stringifiedReturnValue = tryCatch(JSON.stringify, JSON, [
424
- returnValue,
425
- ]);
426
- if (stringifiedReturnValue === errorObject) {
427
- throw errorObject.value;
428
- }
429
- const args = this.scripts.moveToCompletedArgs(this, stringifiedReturnValue, this.opts.removeOnComplete, token, fetchNext);
430
- const result = await this.scripts.moveToFinished(this.id, args);
431
- this.finishedOn = args[this.scripts.moveToFinishedKeys.length + 1];
432
- this.attemptsMade += 1;
433
- return result;
446
+ return this.queue.trace(SpanKind.INTERNAL, 'complete', this.queue.name, async (span, dstPropagationMedatadata) => {
447
+ var _a, _b;
448
+ let tm;
449
+ if (!((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.omitContext) && dstPropagationMedatadata) {
450
+ tm = dstPropagationMedatadata;
451
+ }
452
+ await this.queue.waitUntilReady();
453
+ this.returnvalue = returnValue || void 0;
454
+ const stringifiedReturnValue = tryCatch(JSON.stringify, JSON, [
455
+ returnValue,
456
+ ]);
457
+ if (stringifiedReturnValue === errorObject) {
458
+ throw errorObject.value;
459
+ }
460
+ const args = this.scripts.moveToCompletedArgs(this, stringifiedReturnValue, this.opts.removeOnComplete, token, fetchNext);
461
+ const result = await this.scripts.moveToFinished(this.id, args);
462
+ this.finishedOn = args[this.scripts.moveToFinishedKeys.length + 1];
463
+ this.attemptsMade += 1;
464
+ return result;
465
+ });
466
+ }
467
+ /**
468
+ * Moves a job to the wait or prioritized state.
469
+ *
470
+ * @param token - Worker token used to acquire completed job.
471
+ * @returns Returns pttl.
472
+ */
473
+ moveToWait(token) {
474
+ return this.scripts.moveJobFromActiveToWait(this.id, token);
434
475
  }
435
476
  async shouldRetryJob(err) {
436
477
  if (this.attemptsMade + 1 < this.opts.attempts &&
@@ -454,7 +495,9 @@ export class Job {
454
495
  */
455
496
  async moveToFailed(err, token, fetchNext = false) {
456
497
  this.failedReason = err === null || err === void 0 ? void 0 : err.message;
457
- return this.queue.trace(SpanKind.INTERNAL, this.getSpanOperation('moveToFailed'), this.queue.name, async (span, dstPropagationMedatadata) => {
498
+ // Check if an automatic retry should be performed
499
+ const [shouldRetry, retryDelay] = await this.shouldRetryJob(err);
500
+ return this.queue.trace(SpanKind.INTERNAL, this.getSpanOperation(shouldRetry, retryDelay), this.queue.name, async (span, dstPropagationMedatadata) => {
458
501
  var _a, _b;
459
502
  let tm;
460
503
  if (!((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.omitContext) && dstPropagationMedatadata) {
@@ -467,11 +510,7 @@ export class Job {
467
510
  stacktrace: JSON.stringify(this.stacktrace),
468
511
  tm,
469
512
  };
470
- //
471
- // Check if an automatic retry should be performed
472
- //
473
513
  let finishedOn;
474
- const [shouldRetry, retryDelay] = await this.shouldRetryJob(err);
475
514
  if (shouldRetry) {
476
515
  if (retryDelay) {
477
516
  // Retry with delay
@@ -499,15 +538,14 @@ export class Job {
499
538
  return result;
500
539
  });
501
540
  }
502
- getSpanOperation(command) {
503
- switch (command) {
504
- case 'moveToDelayed':
541
+ getSpanOperation(shouldRetry, retryDelay) {
542
+ if (shouldRetry) {
543
+ if (retryDelay) {
505
544
  return 'delay';
506
- case 'retryJob':
507
- return 'retry';
508
- case 'moveToFinished':
509
- return 'fail';
545
+ }
546
+ return 'retry';
510
547
  }
548
+ return 'fail';
511
549
  }
512
550
  /**
513
551
  * @returns true if the job has completed.
@@ -599,7 +637,20 @@ export class Job {
599
637
  }
600
638
  }
601
639
  /**
602
- * Get this jobs children failure values if any.
640
+ * Retrieves the failures of child jobs that were explicitly ignored while using ignoreDependencyOnFailure option.
641
+ * This method is useful for inspecting which child jobs were intentionally ignored when an error occured.
642
+ * @see {@link https://docs.bullmq.io/guide/flows/ignore-dependency}
643
+ *
644
+ * @returns Object mapping children job keys with their failure values.
645
+ */
646
+ async getIgnoredChildrenFailures() {
647
+ const client = await this.queue.client;
648
+ return client.hgetall(this.toKey(`${this.id}:failed`));
649
+ }
650
+ /**
651
+ * Get job's children failure values that were ignored if any.
652
+ *
653
+ * @deprecated This method is deprecated and will be removed in v6. Use getIgnoredChildrenFailures instead.
603
654
  *
604
655
  * @returns Object mapping children job keys with their failure values.
605
656
  */
@@ -614,52 +665,108 @@ export class Job {
614
665
  * on processed/unprocessed dependencies, since v7.2 you must consider that count
615
666
  * won't have any effect until processed/unprocessed dependencies have a length
616
667
  * greater than 127
617
- * @see https://redis.io/docs/management/optimization/memory-optimization/#redis--72
618
- * @returns dependencies separated by processed and unprocessed.
668
+ * @see {@link https://redis.io/docs/management/optimization/memory-optimization/#redis--72}
669
+ * @see {@link https://docs.bullmq.io/guide/flows#getters}
670
+ * @returns dependencies separated by processed, unprocessed, ignored and failed.
619
671
  */
620
672
  async getDependencies(opts = {}) {
621
673
  const client = await this.queue.client;
622
674
  const multi = client.multi();
623
- if (!opts.processed && !opts.unprocessed) {
675
+ if (!opts.processed && !opts.unprocessed && !opts.ignored && !opts.failed) {
624
676
  multi.hgetall(this.toKey(`${this.id}:processed`));
625
677
  multi.smembers(this.toKey(`${this.id}:dependencies`));
626
- const [[err1, processed], [err2, unprocessed]] = (await multi.exec());
627
- const transformedProcessed = parseObjectValues(processed);
628
- return { processed: transformedProcessed, unprocessed };
678
+ multi.hgetall(this.toKey(`${this.id}:failed`));
679
+ multi.zrange(this.toKey(`${this.id}:unsuccessful`), 0, -1);
680
+ const [[err1, processed], [err2, unprocessed], [err3, ignored], [err4, failed],] = (await multi.exec());
681
+ return {
682
+ processed: parseObjectValues(processed),
683
+ unprocessed,
684
+ failed,
685
+ ignored,
686
+ };
629
687
  }
630
688
  else {
631
689
  const defaultOpts = {
632
690
  cursor: 0,
633
691
  count: 20,
634
692
  };
693
+ const childrenResultOrder = [];
635
694
  if (opts.processed) {
695
+ childrenResultOrder.push('processed');
636
696
  const processedOpts = Object.assign(Object.assign({}, defaultOpts), opts.processed);
637
697
  multi.hscan(this.toKey(`${this.id}:processed`), processedOpts.cursor, 'COUNT', processedOpts.count);
638
698
  }
639
699
  if (opts.unprocessed) {
700
+ childrenResultOrder.push('unprocessed');
640
701
  const unprocessedOpts = Object.assign(Object.assign({}, defaultOpts), opts.unprocessed);
641
702
  multi.sscan(this.toKey(`${this.id}:dependencies`), unprocessedOpts.cursor, 'COUNT', unprocessedOpts.count);
642
703
  }
643
- const [result1, result2] = (await multi.exec());
644
- const [processedCursor, processed = []] = opts.processed
645
- ? result1[1]
646
- : [];
647
- const [unprocessedCursor, unprocessed = []] = opts.unprocessed
648
- ? opts.processed
649
- ? result2[1]
650
- : result1[1]
651
- : [];
652
- const transformedProcessed = {};
653
- for (let index = 0; index < processed.length; ++index) {
654
- if (index % 2) {
655
- transformedProcessed[processed[index - 1]] = JSON.parse(processed[index]);
656
- }
704
+ if (opts.ignored) {
705
+ childrenResultOrder.push('ignored');
706
+ const ignoredOpts = Object.assign(Object.assign({}, defaultOpts), opts.ignored);
707
+ multi.hscan(this.toKey(`${this.id}:failed`), ignoredOpts.cursor, 'COUNT', ignoredOpts.count);
657
708
  }
658
- return Object.assign(Object.assign({}, (processedCursor
709
+ let failedCursor;
710
+ if (opts.failed) {
711
+ childrenResultOrder.push('failed');
712
+ const failedOpts = Object.assign(Object.assign({}, defaultOpts), opts.failed);
713
+ failedCursor = failedOpts.cursor + failedOpts.count;
714
+ multi.zrange(this.toKey(`${this.id}:unsuccessful`), failedOpts.cursor, failedOpts.count - 1);
715
+ }
716
+ const results = (await multi.exec());
717
+ let processedCursor, processed, unprocessedCursor, unprocessed, failed, ignoredCursor, ignored;
718
+ childrenResultOrder.forEach((key, index) => {
719
+ switch (key) {
720
+ case 'processed': {
721
+ processedCursor = results[index][1][0];
722
+ const rawProcessed = results[index][1][1];
723
+ const transformedProcessed = {};
724
+ for (let ind = 0; ind < rawProcessed.length; ++ind) {
725
+ if (ind % 2) {
726
+ transformedProcessed[rawProcessed[ind - 1]] = JSON.parse(rawProcessed[ind]);
727
+ }
728
+ }
729
+ processed = transformedProcessed;
730
+ break;
731
+ }
732
+ case 'failed': {
733
+ failed = results[index][1];
734
+ break;
735
+ }
736
+ case 'ignored': {
737
+ ignoredCursor = results[index][1][0];
738
+ const rawIgnored = results[index][1][1];
739
+ const transformedIgnored = {};
740
+ for (let ind = 0; ind < rawIgnored.length; ++ind) {
741
+ if (ind % 2) {
742
+ transformedIgnored[rawIgnored[ind - 1]] = rawIgnored[ind];
743
+ }
744
+ }
745
+ ignored = transformedIgnored;
746
+ break;
747
+ }
748
+ case 'unprocessed': {
749
+ unprocessedCursor = results[index][1][0];
750
+ unprocessed = results[index][1][1];
751
+ break;
752
+ }
753
+ }
754
+ });
755
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (processedCursor
659
756
  ? {
660
- processed: transformedProcessed,
757
+ processed,
661
758
  nextProcessedCursor: Number(processedCursor),
662
759
  }
760
+ : {})), (ignoredCursor
761
+ ? {
762
+ ignored,
763
+ nextIgnoredCursor: Number(ignoredCursor),
764
+ }
765
+ : {})), (failedCursor
766
+ ? {
767
+ failed,
768
+ nextFailedCursor: failedCursor,
769
+ }
663
770
  : {})), (unprocessedCursor
664
771
  ? { unprocessed, nextUnprocessedCursor: Number(unprocessedCursor) }
665
772
  : {}));
@@ -668,32 +775,24 @@ export class Job {
668
775
  /**
669
776
  * Get children job counts if this job is a parent and has children.
670
777
  *
671
- * @returns dependencies count separated by processed and unprocessed.
778
+ * @returns dependencies count separated by processed, unprocessed, ignored and failed.
672
779
  */
673
780
  async getDependenciesCount(opts = {}) {
674
- const client = await this.queue.client;
675
- const multi = client.multi();
676
- const updatedOpts = !opts.processed && !opts.unprocessed
677
- ? { processed: true, unprocessed: true }
678
- : opts;
679
- if (updatedOpts.processed) {
680
- multi.hlen(this.toKey(`${this.id}:processed`));
681
- }
682
- if (updatedOpts.unprocessed) {
683
- multi.scard(this.toKey(`${this.id}:dependencies`));
684
- }
685
- const [[err1, result1] = [], [err2, result2] = []] = (await multi.exec());
686
- const processed = updatedOpts.processed ? result1 : undefined;
687
- const unprocessed = updatedOpts.unprocessed
688
- ? updatedOpts.processed
689
- ? result2
690
- : result1
691
- : undefined;
692
- return Object.assign(Object.assign({}, (updatedOpts.processed
693
- ? {
694
- processed,
781
+ const types = [];
782
+ Object.entries(opts).forEach(([key, value]) => {
783
+ if (value) {
784
+ types.push(key);
695
785
  }
696
- : {})), (updatedOpts.unprocessed ? { unprocessed } : {}));
786
+ });
787
+ const finalTypes = types.length
788
+ ? types
789
+ : ['processed', 'unprocessed', 'ignored', 'failed'];
790
+ const responses = await this.scripts.getDependencyCounts(this.id, finalTypes);
791
+ const counts = {};
792
+ responses.forEach((res, index) => {
793
+ counts[`${finalTypes[index]}`] = res || 0;
794
+ });
795
+ return counts;
697
796
  }
698
797
  /**
699
798
  * Returns a promise the resolves when the job has completed (containing the return value of the job),
@@ -799,6 +898,7 @@ export class Job {
799
898
  }
800
899
  /**
801
900
  * Marks a job to not be retried if it fails (even if attempts has been configured)
901
+ * @deprecated use UnrecoverableError
802
902
  */
803
903
  discard() {
804
904
  this.discarded = true;
@@ -825,6 +925,12 @@ export class Job {
825
925
  }
826
926
  validateOptions(jobData) {
827
927
  var _a;
928
+ const exclusiveOptions = [
929
+ 'removeDependencyOnFailure',
930
+ 'failParentOnFailure',
931
+ 'continueParentOnFailure',
932
+ 'ignoreDependencyOnFailure',
933
+ ];
828
934
  const exceedLimit = this.opts.sizeLimit &&
829
935
  lengthInUtf8Bytes(jobData.data) > this.opts.sizeLimit;
830
936
  if (exceedLimit) {
@@ -833,15 +939,10 @@ export class Job {
833
939
  if (this.opts.delay && this.opts.repeat && !((_a = this.opts.repeat) === null || _a === void 0 ? void 0 : _a.count)) {
834
940
  throw new Error(`Delay and repeat options could not be used together`);
835
941
  }
836
- if (this.opts.removeDependencyOnFailure && this.opts.failParentOnFailure) {
837
- throw new Error(`RemoveDependencyOnFailure and failParentOnFailure options can not be used together`);
838
- }
839
- if (this.opts.removeDependencyOnFailure &&
840
- this.opts.ignoreDependencyOnFailure) {
841
- throw new Error(`RemoveDependencyOnFailure and ignoreDependencyOnFailure options can not be used together`);
842
- }
843
- if (this.opts.failParentOnFailure && this.opts.ignoreDependencyOnFailure) {
844
- throw new Error(`FailParentOnFailure and ignoreDependencyOnFailure options can not be used together`);
942
+ const enabledExclusiveOptions = exclusiveOptions.filter(opt => this.opts[opt]);
943
+ if (enabledExclusiveOptions.length > 1) {
944
+ const optionsList = enabledExclusiveOptions.join(', ');
945
+ throw new Error(`The following options cannot be used together: ${optionsList}`);
845
946
  }
846
947
  if (`${parseInt(this.id, 10)}` === this.id) {
847
948
  throw new Error('Custom Ids cannot be integers');
@@ -854,6 +955,12 @@ export class Job {
854
955
  throw new Error(`Priority should be between 0 and ${PRIORITY_LIMIT}`);
855
956
  }
856
957
  }
958
+ if (typeof this.opts.backoff === 'object' &&
959
+ typeof this.opts.backoff.jitter === 'number') {
960
+ if (this.opts.backoff.jitter < 0 || this.opts.backoff.jitter > 1) {
961
+ throw new Error(`Jitter should be between 0 and 1`);
962
+ }
963
+ }
857
964
  }
858
965
  updateStacktrace(err) {
859
966
  this.stacktrace = this.stacktrace || [];
@@ -1,4 +1,3 @@
1
- declare const _default: (send: (msg: any) => Promise<void>, receiver: {
2
- on: (evt: 'message', cb: (msg: any) => void) => void;
3
- }) => void;
1
+ import { Receiver } from '../interfaces';
2
+ declare const _default: (send: (msg: any) => Promise<void>, receiver: Receiver) => void;
4
3
  export default _default;
@@ -6,7 +6,7 @@ import { ChildProcessor } from './child-processor';
6
6
  import { ParentCommand, ChildCommand } from '../enums';
7
7
  import { errorToJSON, toString } from '../utils';
8
8
  export default (send, receiver) => {
9
- const childProcessor = new ChildProcessor(send);
9
+ const childProcessor = new ChildProcessor(send, receiver);
10
10
  receiver === null || receiver === void 0 ? void 0 : receiver.on('message', async (msg) => {
11
11
  try {
12
12
  switch (msg.cmd) {
@@ -8,10 +8,7 @@ import { KeysMap } from './queue-keys';
8
8
  import { Scripts } from './scripts';
9
9
  import { SpanKind } from '../enums';
10
10
  /**
11
- * @class QueueBase
12
- * @extends EventEmitter
13
- *
14
- * @description Base class for all classes that need to interact with queues.
11
+ * Base class for all classes that need to interact with queues.
15
12
  * This class is normally not used directly, but extended by the other classes.
16
13
  *
17
14
  */
@@ -38,7 +35,7 @@ export declare class QueueBase extends EventEmitter implements MinimalQueue {
38
35
  * Returns a promise that resolves to a redis client. Normally used only by subclasses.
39
36
  */
40
37
  get client(): Promise<RedisClient>;
41
- protected setScripts(): void;
38
+ protected createScripts(): void;
42
39
  /**
43
40
  * Returns the version of the Redis instance the client is connected to,
44
41
  */
@@ -1,14 +1,10 @@
1
1
  import { EventEmitter } from 'events';
2
- import { delay, DELAY_TIME_5, isNotConnectionError, isRedisInstance, trace, } from '../utils';
2
+ import { createScripts, delay, DELAY_TIME_5, isNotConnectionError, isRedisInstance, trace, } from '../utils';
3
3
  import { RedisConnection } from './redis-connection';
4
4
  import { Job } from './job';
5
5
  import { QueueKeys } from './queue-keys';
6
- import { Scripts } from './scripts';
7
6
  /**
8
- * @class QueueBase
9
- * @extends EventEmitter
10
- *
11
- * @description Base class for all classes that need to interact with queues.
7
+ * Base class for all classes that need to interact with queues.
12
8
  * This class is normally not used directly, but extended by the other classes.
13
9
  *
14
10
  */
@@ -34,7 +30,12 @@ export class QueueBase extends EventEmitter {
34
30
  if (name.includes(':')) {
35
31
  throw new Error('Queue name cannot contain :');
36
32
  }
37
- this.connection = new Connection(opts.connection, isRedisInstance(opts.connection), hasBlockingConnection, opts.skipVersionCheck);
33
+ this.connection = new Connection(opts.connection, {
34
+ shared: isRedisInstance(opts.connection),
35
+ blocking: hasBlockingConnection,
36
+ skipVersionCheck: opts.skipVersionCheck,
37
+ skipWaitingForReady: opts.skipWaitingForReady,
38
+ });
38
39
  this.connection.on('error', (error) => this.emit('error', error));
39
40
  this.connection.on('close', () => {
40
41
  if (!this.closing) {
@@ -45,7 +46,7 @@ export class QueueBase extends EventEmitter {
45
46
  this.qualifiedName = queueKeys.getQueueQualifiedName(name);
46
47
  this.keys = queueKeys.getKeys(name);
47
48
  this.toKey = (type) => queueKeys.toKey(name, type);
48
- this.setScripts();
49
+ this.createScripts();
49
50
  }
50
51
  /**
51
52
  * Returns a promise that resolves to a redis client. Normally used only by subclasses.
@@ -53,8 +54,8 @@ export class QueueBase extends EventEmitter {
53
54
  get client() {
54
55
  return this.connection.client;
55
56
  }
56
- setScripts() {
57
- this.scripts = new Scripts(this);
57
+ createScripts() {
58
+ this.scripts = createScripts(this);
58
59
  }
59
60
  /**
60
61
  * Returns the version of the Redis instance the client is connected to,
@@ -1,11 +1,11 @@
1
- import { QueueBaseOptions } from '../interfaces';
1
+ import { QueueEventsProducerOptions } from '../interfaces';
2
2
  import { QueueBase } from './queue-base';
3
3
  import { RedisConnection } from './redis-connection';
4
4
  /**
5
5
  * The QueueEventsProducer class is used for publishing custom events.
6
6
  */
7
7
  export declare class QueueEventsProducer extends QueueBase {
8
- constructor(name: string, opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
8
+ constructor(name: string, opts?: QueueEventsProducerOptions, Connection?: typeof RedisConnection);
9
9
  /**
10
10
  * Publish custom event to be processed in QueueEvents.
11
11
  * @param argsObj - Event payload