@tachybase/plugin-adapter-bullmq 1.3.17 → 1.3.19

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 +6 -6
  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
@@ -5,20 +5,9 @@ const tslib_1 = require("tslib");
5
5
  const util_1 = require("util");
6
6
  const utils_1 = require("../utils");
7
7
  const backoffs_1 = require("./backoffs");
8
- const scripts_1 = require("./scripts");
9
8
  const unrecoverable_error_1 = require("./errors/unrecoverable-error");
10
9
  const enums_1 = require("../enums");
11
10
  const logger = (0, util_1.debuglog)('bull');
12
- // Simple options decode map.
13
- const optsDecodeMap = {
14
- de: 'deduplication',
15
- fpof: 'failParentOnFailure',
16
- idof: 'ignoreDependencyOnFailure',
17
- kl: 'keepLogs',
18
- rdof: 'removeDependencyOnFailure',
19
- };
20
- const optsEncodeMap = Object.assign(Object.assign({}, (0, utils_1.invertObject)(optsDecodeMap)), {
21
- /*/ Legacy for backwards compatibility */ debounce: 'de' });
22
11
  exports.PRIORITY_LIMIT = 2 ** 21;
23
12
  /**
24
13
  * Job
@@ -28,7 +17,6 @@ exports.PRIORITY_LIMIT = 2 ** 21;
28
17
  *
29
18
  * A Job instance is also passed to the Worker's process function.
30
19
  *
31
- * @class Job
32
20
  */
33
21
  class Job {
34
22
  constructor(queue,
@@ -86,6 +74,11 @@ class Job {
86
74
  * @defaultValue 0
87
75
  */
88
76
  this.attemptsMade = 0;
77
+ /**
78
+ * Number of times where job has stalled.
79
+ * @defaultValue 0
80
+ */
81
+ this.stalledCounter = 0;
89
82
  const _a = this.opts, { repeatJobKey } = _a, restOpts = tslib_1.__rest(_a, ["repeatJobKey"]);
90
83
  this.opts = Object.assign({
91
84
  attempts: 0,
@@ -96,15 +89,27 @@ class Job {
96
89
  this.timestamp = opts.timestamp ? opts.timestamp : Date.now();
97
90
  this.opts.backoff = backoffs_1.Backoffs.normalize(opts.backoff);
98
91
  this.parentKey = (0, utils_1.getParentKey)(opts.parent);
99
- this.parent = opts.parent
100
- ? { id: opts.parent.id, queueKey: opts.parent.queue }
101
- : undefined;
92
+ if (opts.parent) {
93
+ this.parent = { id: opts.parent.id, queueKey: opts.parent.queue };
94
+ if (opts.failParentOnFailure) {
95
+ this.parent.fpof = true;
96
+ }
97
+ if (opts.removeDependencyOnFailure) {
98
+ this.parent.rdof = true;
99
+ }
100
+ if (opts.ignoreDependencyOnFailure) {
101
+ this.parent.idof = true;
102
+ }
103
+ if (opts.continueParentOnFailure) {
104
+ this.parent.cpof = true;
105
+ }
106
+ }
102
107
  this.debounceId = opts.debounce ? opts.debounce.id : undefined;
103
108
  this.deduplicationId = opts.deduplication
104
109
  ? opts.deduplication.id
105
110
  : this.debounceId;
106
111
  this.toKey = queue.toKey.bind(queue);
107
- this.setScripts();
112
+ this.createScripts();
108
113
  this.queueQualifiedName = queue.qualifiedName;
109
114
  }
110
115
  /**
@@ -170,6 +175,7 @@ class Job {
170
175
  const job = new this(queue, json.name, data, opts, json.id || jobId);
171
176
  job.progress = JSON.parse(json.progress || '0');
172
177
  job.delay = parseInt(json.delay);
178
+ job.priority = parseInt(json.priority);
173
179
  job.timestamp = parseInt(json.timestamp);
174
180
  if (json.finishedOn) {
175
181
  job.finishedOn = parseInt(json.finishedOn);
@@ -184,9 +190,15 @@ class Job {
184
190
  job.debounceId = json.deid;
185
191
  job.deduplicationId = json.deid;
186
192
  }
187
- job.failedReason = json.failedReason;
193
+ if (json.failedReason) {
194
+ job.failedReason = json.failedReason;
195
+ }
188
196
  job.attemptsStarted = parseInt(json.ats || '0');
189
197
  job.attemptsMade = parseInt(json.attemptsMade || json.atm || '0');
198
+ job.stalledCounter = parseInt(json.stc || '0');
199
+ if (json.defa) {
200
+ job.deferredFailure = json.defa;
201
+ }
190
202
  job.stacktrace = getTraces(json.stacktrace);
191
203
  if (typeof json.returnvalue === 'string') {
192
204
  job.returnvalue = getReturnValue(json.returnvalue);
@@ -205,17 +217,17 @@ class Job {
205
217
  }
206
218
  return job;
207
219
  }
208
- setScripts() {
209
- this.scripts = new scripts_1.Scripts(this.queue);
220
+ createScripts() {
221
+ this.scripts = (0, utils_1.createScripts)(this.queue);
210
222
  }
211
- static optsFromJSON(rawOpts) {
223
+ static optsFromJSON(rawOpts, optsDecode = utils_1.optsDecodeMap) {
212
224
  const opts = JSON.parse(rawOpts || '{}');
213
225
  const optionEntries = Object.entries(opts);
214
226
  const options = {};
215
227
  for (const item of optionEntries) {
216
228
  const [attributeName, value] = item;
217
- if (optsDecodeMap[attributeName]) {
218
- options[optsDecodeMap[attributeName]] =
229
+ if (optsDecode[attributeName]) {
230
+ options[optsDecode[attributeName]] =
219
231
  value;
220
232
  }
221
233
  else {
@@ -252,10 +264,10 @@ class Job {
252
264
  /**
253
265
  * addJobLog
254
266
  *
255
- * @param queue Queue instance
256
- * @param jobId Job id
257
- * @param logRow Log row
258
- * @param keepLogs optional maximum number of logs to keep
267
+ * @param queue - A minimal queue instance
268
+ * @param jobId - Job id
269
+ * @param logRow - String with a row of log data to be logged
270
+ * @param keepLogs - The optional amount of log entries to preserve
259
271
  *
260
272
  * @returns The total number of log entries for this job so far.
261
273
  */
@@ -282,6 +294,7 @@ class Job {
282
294
  progress: this.progress,
283
295
  attemptsMade: this.attemptsMade,
284
296
  attemptsStarted: this.attemptsStarted,
297
+ stalledCounter: this.stalledCounter,
285
298
  finishedOn: this.finishedOn,
286
299
  processedOn: this.processedOn,
287
300
  timestamp: this.timestamp,
@@ -294,16 +307,16 @@ class Job {
294
307
  nrjid: this.nextRepeatableJobId,
295
308
  });
296
309
  }
297
- static optsAsJSON(opts = {}) {
310
+ static optsAsJSON(opts = {}, optsEncode = utils_1.optsEncodeMap) {
298
311
  const optionEntries = Object.entries(opts);
299
312
  const options = {};
300
313
  for (const [attributeName, value] of optionEntries) {
301
314
  if (typeof value === 'undefined') {
302
315
  continue;
303
316
  }
304
- if (attributeName in optsEncodeMap) {
317
+ if (attributeName in optsEncode) {
305
318
  const compressableAttribute = attributeName;
306
- const key = optsEncodeMap[compressableAttribute];
319
+ const key = optsEncode[compressableAttribute];
307
320
  options[key] = value;
308
321
  }
309
322
  else {
@@ -402,6 +415,18 @@ class Job {
402
415
  throw new Error(`Job ${this.id} could not be removed because it is locked by another worker`);
403
416
  }
404
417
  }
418
+ /**
419
+ * Remove all children from this job that are not yet processed,
420
+ * in other words that are in any other state than completed, failed or active.
421
+ *
422
+ * @remarks
423
+ * - Jobs with locks (most likely active) are ignored.
424
+ * - This method can be slow if the number of children is large (\> 1000).
425
+ */
426
+ async removeUnprocessedChildren() {
427
+ const jobId = this.id;
428
+ await this.scripts.removeUnprocessedChildren(jobId);
429
+ }
405
430
  /**
406
431
  * Extend the lock for this job.
407
432
  *
@@ -421,19 +446,35 @@ class Job {
421
446
  * @returns Returns the jobData of the next job in the waiting queue or void.
422
447
  */
423
448
  async moveToCompleted(returnValue, token, fetchNext = true) {
424
- await this.queue.waitUntilReady();
425
- this.returnvalue = returnValue || void 0;
426
- const stringifiedReturnValue = (0, utils_1.tryCatch)(JSON.stringify, JSON, [
427
- returnValue,
428
- ]);
429
- if (stringifiedReturnValue === utils_1.errorObject) {
430
- throw utils_1.errorObject.value;
431
- }
432
- const args = this.scripts.moveToCompletedArgs(this, stringifiedReturnValue, this.opts.removeOnComplete, token, fetchNext);
433
- const result = await this.scripts.moveToFinished(this.id, args);
434
- this.finishedOn = args[this.scripts.moveToFinishedKeys.length + 1];
435
- this.attemptsMade += 1;
436
- return result;
449
+ return this.queue.trace(enums_1.SpanKind.INTERNAL, 'complete', this.queue.name, async (span, dstPropagationMedatadata) => {
450
+ var _a, _b;
451
+ let tm;
452
+ if (!((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.omitContext) && dstPropagationMedatadata) {
453
+ tm = dstPropagationMedatadata;
454
+ }
455
+ await this.queue.waitUntilReady();
456
+ this.returnvalue = returnValue || void 0;
457
+ const stringifiedReturnValue = (0, utils_1.tryCatch)(JSON.stringify, JSON, [
458
+ returnValue,
459
+ ]);
460
+ if (stringifiedReturnValue === utils_1.errorObject) {
461
+ throw utils_1.errorObject.value;
462
+ }
463
+ const args = this.scripts.moveToCompletedArgs(this, stringifiedReturnValue, this.opts.removeOnComplete, token, fetchNext);
464
+ const result = await this.scripts.moveToFinished(this.id, args);
465
+ this.finishedOn = args[this.scripts.moveToFinishedKeys.length + 1];
466
+ this.attemptsMade += 1;
467
+ return result;
468
+ });
469
+ }
470
+ /**
471
+ * Moves a job to the wait or prioritized state.
472
+ *
473
+ * @param token - Worker token used to acquire completed job.
474
+ * @returns Returns pttl.
475
+ */
476
+ moveToWait(token) {
477
+ return this.scripts.moveJobFromActiveToWait(this.id, token);
437
478
  }
438
479
  async shouldRetryJob(err) {
439
480
  if (this.attemptsMade + 1 < this.opts.attempts &&
@@ -457,7 +498,9 @@ class Job {
457
498
  */
458
499
  async moveToFailed(err, token, fetchNext = false) {
459
500
  this.failedReason = err === null || err === void 0 ? void 0 : err.message;
460
- return this.queue.trace(enums_1.SpanKind.INTERNAL, this.getSpanOperation('moveToFailed'), this.queue.name, async (span, dstPropagationMedatadata) => {
501
+ // Check if an automatic retry should be performed
502
+ const [shouldRetry, retryDelay] = await this.shouldRetryJob(err);
503
+ return this.queue.trace(enums_1.SpanKind.INTERNAL, this.getSpanOperation(shouldRetry, retryDelay), this.queue.name, async (span, dstPropagationMedatadata) => {
461
504
  var _a, _b;
462
505
  let tm;
463
506
  if (!((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.omitContext) && dstPropagationMedatadata) {
@@ -470,11 +513,7 @@ class Job {
470
513
  stacktrace: JSON.stringify(this.stacktrace),
471
514
  tm,
472
515
  };
473
- //
474
- // Check if an automatic retry should be performed
475
- //
476
516
  let finishedOn;
477
- const [shouldRetry, retryDelay] = await this.shouldRetryJob(err);
478
517
  if (shouldRetry) {
479
518
  if (retryDelay) {
480
519
  // Retry with delay
@@ -502,15 +541,14 @@ class Job {
502
541
  return result;
503
542
  });
504
543
  }
505
- getSpanOperation(command) {
506
- switch (command) {
507
- case 'moveToDelayed':
544
+ getSpanOperation(shouldRetry, retryDelay) {
545
+ if (shouldRetry) {
546
+ if (retryDelay) {
508
547
  return 'delay';
509
- case 'retryJob':
510
- return 'retry';
511
- case 'moveToFinished':
512
- return 'fail';
548
+ }
549
+ return 'retry';
513
550
  }
551
+ return 'fail';
514
552
  }
515
553
  /**
516
554
  * @returns true if the job has completed.
@@ -602,7 +640,20 @@ class Job {
602
640
  }
603
641
  }
604
642
  /**
605
- * Get this jobs children failure values if any.
643
+ * Retrieves the failures of child jobs that were explicitly ignored while using ignoreDependencyOnFailure option.
644
+ * This method is useful for inspecting which child jobs were intentionally ignored when an error occured.
645
+ * @see {@link https://docs.bullmq.io/guide/flows/ignore-dependency}
646
+ *
647
+ * @returns Object mapping children job keys with their failure values.
648
+ */
649
+ async getIgnoredChildrenFailures() {
650
+ const client = await this.queue.client;
651
+ return client.hgetall(this.toKey(`${this.id}:failed`));
652
+ }
653
+ /**
654
+ * Get job's children failure values that were ignored if any.
655
+ *
656
+ * @deprecated This method is deprecated and will be removed in v6. Use getIgnoredChildrenFailures instead.
606
657
  *
607
658
  * @returns Object mapping children job keys with their failure values.
608
659
  */
@@ -617,52 +668,108 @@ class Job {
617
668
  * on processed/unprocessed dependencies, since v7.2 you must consider that count
618
669
  * won't have any effect until processed/unprocessed dependencies have a length
619
670
  * greater than 127
620
- * @see https://redis.io/docs/management/optimization/memory-optimization/#redis--72
621
- * @returns dependencies separated by processed and unprocessed.
671
+ * @see {@link https://redis.io/docs/management/optimization/memory-optimization/#redis--72}
672
+ * @see {@link https://docs.bullmq.io/guide/flows#getters}
673
+ * @returns dependencies separated by processed, unprocessed, ignored and failed.
622
674
  */
623
675
  async getDependencies(opts = {}) {
624
676
  const client = await this.queue.client;
625
677
  const multi = client.multi();
626
- if (!opts.processed && !opts.unprocessed) {
678
+ if (!opts.processed && !opts.unprocessed && !opts.ignored && !opts.failed) {
627
679
  multi.hgetall(this.toKey(`${this.id}:processed`));
628
680
  multi.smembers(this.toKey(`${this.id}:dependencies`));
629
- const [[err1, processed], [err2, unprocessed]] = (await multi.exec());
630
- const transformedProcessed = (0, utils_1.parseObjectValues)(processed);
631
- return { processed: transformedProcessed, unprocessed };
681
+ multi.hgetall(this.toKey(`${this.id}:failed`));
682
+ multi.zrange(this.toKey(`${this.id}:unsuccessful`), 0, -1);
683
+ const [[err1, processed], [err2, unprocessed], [err3, ignored], [err4, failed],] = (await multi.exec());
684
+ return {
685
+ processed: (0, utils_1.parseObjectValues)(processed),
686
+ unprocessed,
687
+ failed,
688
+ ignored,
689
+ };
632
690
  }
633
691
  else {
634
692
  const defaultOpts = {
635
693
  cursor: 0,
636
694
  count: 20,
637
695
  };
696
+ const childrenResultOrder = [];
638
697
  if (opts.processed) {
698
+ childrenResultOrder.push('processed');
639
699
  const processedOpts = Object.assign(Object.assign({}, defaultOpts), opts.processed);
640
700
  multi.hscan(this.toKey(`${this.id}:processed`), processedOpts.cursor, 'COUNT', processedOpts.count);
641
701
  }
642
702
  if (opts.unprocessed) {
703
+ childrenResultOrder.push('unprocessed');
643
704
  const unprocessedOpts = Object.assign(Object.assign({}, defaultOpts), opts.unprocessed);
644
705
  multi.sscan(this.toKey(`${this.id}:dependencies`), unprocessedOpts.cursor, 'COUNT', unprocessedOpts.count);
645
706
  }
646
- const [result1, result2] = (await multi.exec());
647
- const [processedCursor, processed = []] = opts.processed
648
- ? result1[1]
649
- : [];
650
- const [unprocessedCursor, unprocessed = []] = opts.unprocessed
651
- ? opts.processed
652
- ? result2[1]
653
- : result1[1]
654
- : [];
655
- const transformedProcessed = {};
656
- for (let index = 0; index < processed.length; ++index) {
657
- if (index % 2) {
658
- transformedProcessed[processed[index - 1]] = JSON.parse(processed[index]);
659
- }
707
+ if (opts.ignored) {
708
+ childrenResultOrder.push('ignored');
709
+ const ignoredOpts = Object.assign(Object.assign({}, defaultOpts), opts.ignored);
710
+ multi.hscan(this.toKey(`${this.id}:failed`), ignoredOpts.cursor, 'COUNT', ignoredOpts.count);
660
711
  }
661
- return Object.assign(Object.assign({}, (processedCursor
712
+ let failedCursor;
713
+ if (opts.failed) {
714
+ childrenResultOrder.push('failed');
715
+ const failedOpts = Object.assign(Object.assign({}, defaultOpts), opts.failed);
716
+ failedCursor = failedOpts.cursor + failedOpts.count;
717
+ multi.zrange(this.toKey(`${this.id}:unsuccessful`), failedOpts.cursor, failedOpts.count - 1);
718
+ }
719
+ const results = (await multi.exec());
720
+ let processedCursor, processed, unprocessedCursor, unprocessed, failed, ignoredCursor, ignored;
721
+ childrenResultOrder.forEach((key, index) => {
722
+ switch (key) {
723
+ case 'processed': {
724
+ processedCursor = results[index][1][0];
725
+ const rawProcessed = results[index][1][1];
726
+ const transformedProcessed = {};
727
+ for (let ind = 0; ind < rawProcessed.length; ++ind) {
728
+ if (ind % 2) {
729
+ transformedProcessed[rawProcessed[ind - 1]] = JSON.parse(rawProcessed[ind]);
730
+ }
731
+ }
732
+ processed = transformedProcessed;
733
+ break;
734
+ }
735
+ case 'failed': {
736
+ failed = results[index][1];
737
+ break;
738
+ }
739
+ case 'ignored': {
740
+ ignoredCursor = results[index][1][0];
741
+ const rawIgnored = results[index][1][1];
742
+ const transformedIgnored = {};
743
+ for (let ind = 0; ind < rawIgnored.length; ++ind) {
744
+ if (ind % 2) {
745
+ transformedIgnored[rawIgnored[ind - 1]] = rawIgnored[ind];
746
+ }
747
+ }
748
+ ignored = transformedIgnored;
749
+ break;
750
+ }
751
+ case 'unprocessed': {
752
+ unprocessedCursor = results[index][1][0];
753
+ unprocessed = results[index][1][1];
754
+ break;
755
+ }
756
+ }
757
+ });
758
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (processedCursor
662
759
  ? {
663
- processed: transformedProcessed,
760
+ processed,
664
761
  nextProcessedCursor: Number(processedCursor),
665
762
  }
763
+ : {})), (ignoredCursor
764
+ ? {
765
+ ignored,
766
+ nextIgnoredCursor: Number(ignoredCursor),
767
+ }
768
+ : {})), (failedCursor
769
+ ? {
770
+ failed,
771
+ nextFailedCursor: failedCursor,
772
+ }
666
773
  : {})), (unprocessedCursor
667
774
  ? { unprocessed, nextUnprocessedCursor: Number(unprocessedCursor) }
668
775
  : {}));
@@ -671,32 +778,24 @@ class Job {
671
778
  /**
672
779
  * Get children job counts if this job is a parent and has children.
673
780
  *
674
- * @returns dependencies count separated by processed and unprocessed.
781
+ * @returns dependencies count separated by processed, unprocessed, ignored and failed.
675
782
  */
676
783
  async getDependenciesCount(opts = {}) {
677
- const client = await this.queue.client;
678
- const multi = client.multi();
679
- const updatedOpts = !opts.processed && !opts.unprocessed
680
- ? { processed: true, unprocessed: true }
681
- : opts;
682
- if (updatedOpts.processed) {
683
- multi.hlen(this.toKey(`${this.id}:processed`));
684
- }
685
- if (updatedOpts.unprocessed) {
686
- multi.scard(this.toKey(`${this.id}:dependencies`));
687
- }
688
- const [[err1, result1] = [], [err2, result2] = []] = (await multi.exec());
689
- const processed = updatedOpts.processed ? result1 : undefined;
690
- const unprocessed = updatedOpts.unprocessed
691
- ? updatedOpts.processed
692
- ? result2
693
- : result1
694
- : undefined;
695
- return Object.assign(Object.assign({}, (updatedOpts.processed
696
- ? {
697
- processed,
784
+ const types = [];
785
+ Object.entries(opts).forEach(([key, value]) => {
786
+ if (value) {
787
+ types.push(key);
698
788
  }
699
- : {})), (updatedOpts.unprocessed ? { unprocessed } : {}));
789
+ });
790
+ const finalTypes = types.length
791
+ ? types
792
+ : ['processed', 'unprocessed', 'ignored', 'failed'];
793
+ const responses = await this.scripts.getDependencyCounts(this.id, finalTypes);
794
+ const counts = {};
795
+ responses.forEach((res, index) => {
796
+ counts[`${finalTypes[index]}`] = res || 0;
797
+ });
798
+ return counts;
700
799
  }
701
800
  /**
702
801
  * Returns a promise the resolves when the job has completed (containing the return value of the job),
@@ -802,6 +901,7 @@ class Job {
802
901
  }
803
902
  /**
804
903
  * Marks a job to not be retried if it fails (even if attempts has been configured)
904
+ * @deprecated use UnrecoverableError
805
905
  */
806
906
  discard() {
807
907
  this.discarded = true;
@@ -828,6 +928,12 @@ class Job {
828
928
  }
829
929
  validateOptions(jobData) {
830
930
  var _a;
931
+ const exclusiveOptions = [
932
+ 'removeDependencyOnFailure',
933
+ 'failParentOnFailure',
934
+ 'continueParentOnFailure',
935
+ 'ignoreDependencyOnFailure',
936
+ ];
831
937
  const exceedLimit = this.opts.sizeLimit &&
832
938
  (0, utils_1.lengthInUtf8Bytes)(jobData.data) > this.opts.sizeLimit;
833
939
  if (exceedLimit) {
@@ -836,15 +942,10 @@ class Job {
836
942
  if (this.opts.delay && this.opts.repeat && !((_a = this.opts.repeat) === null || _a === void 0 ? void 0 : _a.count)) {
837
943
  throw new Error(`Delay and repeat options could not be used together`);
838
944
  }
839
- if (this.opts.removeDependencyOnFailure && this.opts.failParentOnFailure) {
840
- throw new Error(`RemoveDependencyOnFailure and failParentOnFailure options can not be used together`);
841
- }
842
- if (this.opts.removeDependencyOnFailure &&
843
- this.opts.ignoreDependencyOnFailure) {
844
- throw new Error(`RemoveDependencyOnFailure and ignoreDependencyOnFailure options can not be used together`);
845
- }
846
- if (this.opts.failParentOnFailure && this.opts.ignoreDependencyOnFailure) {
847
- throw new Error(`FailParentOnFailure and ignoreDependencyOnFailure options can not be used together`);
945
+ const enabledExclusiveOptions = exclusiveOptions.filter(opt => this.opts[opt]);
946
+ if (enabledExclusiveOptions.length > 1) {
947
+ const optionsList = enabledExclusiveOptions.join(', ');
948
+ throw new Error(`The following options cannot be used together: ${optionsList}`);
848
949
  }
849
950
  if (`${parseInt(this.id, 10)}` === this.id) {
850
951
  throw new Error('Custom Ids cannot be integers');
@@ -857,6 +958,12 @@ class Job {
857
958
  throw new Error(`Priority should be between 0 and ${exports.PRIORITY_LIMIT}`);
858
959
  }
859
960
  }
961
+ if (typeof this.opts.backoff === 'object' &&
962
+ typeof this.opts.backoff.jitter === 'number') {
963
+ if (this.opts.backoff.jitter < 0 || this.opts.backoff.jitter > 1) {
964
+ throw new Error(`Jitter should be between 0 and 1`);
965
+ }
966
+ }
860
967
  }
861
968
  updateStacktrace(err) {
862
969
  this.stacktrace = this.stacktrace || [];
@@ -8,7 +8,7 @@ const child_processor_1 = require("./child-processor");
8
8
  const enums_1 = require("../enums");
9
9
  const utils_1 = require("../utils");
10
10
  exports.default = (send, receiver) => {
11
- const childProcessor = new child_processor_1.ChildProcessor(send);
11
+ const childProcessor = new child_processor_1.ChildProcessor(send, receiver);
12
12
  receiver === null || receiver === void 0 ? void 0 : receiver.on('message', async (msg) => {
13
13
  try {
14
14
  switch (msg.cmd) {
@@ -6,12 +6,8 @@ const utils_1 = require("../utils");
6
6
  const redis_connection_1 = require("./redis-connection");
7
7
  const job_1 = require("./job");
8
8
  const queue_keys_1 = require("./queue-keys");
9
- const scripts_1 = require("./scripts");
10
9
  /**
11
- * @class QueueBase
12
- * @extends EventEmitter
13
- *
14
- * @description Base class for all classes that need to interact with queues.
10
+ * Base class for all classes that need to interact with queues.
15
11
  * This class is normally not used directly, but extended by the other classes.
16
12
  *
17
13
  */
@@ -37,7 +33,12 @@ class QueueBase extends events_1.EventEmitter {
37
33
  if (name.includes(':')) {
38
34
  throw new Error('Queue name cannot contain :');
39
35
  }
40
- this.connection = new Connection(opts.connection, (0, utils_1.isRedisInstance)(opts.connection), hasBlockingConnection, opts.skipVersionCheck);
36
+ this.connection = new Connection(opts.connection, {
37
+ shared: (0, utils_1.isRedisInstance)(opts.connection),
38
+ blocking: hasBlockingConnection,
39
+ skipVersionCheck: opts.skipVersionCheck,
40
+ skipWaitingForReady: opts.skipWaitingForReady,
41
+ });
41
42
  this.connection.on('error', (error) => this.emit('error', error));
42
43
  this.connection.on('close', () => {
43
44
  if (!this.closing) {
@@ -48,7 +49,7 @@ class QueueBase extends events_1.EventEmitter {
48
49
  this.qualifiedName = queueKeys.getQueueQualifiedName(name);
49
50
  this.keys = queueKeys.getKeys(name);
50
51
  this.toKey = (type) => queueKeys.toKey(name, type);
51
- this.setScripts();
52
+ this.createScripts();
52
53
  }
53
54
  /**
54
55
  * Returns a promise that resolves to a redis client. Normally used only by subclasses.
@@ -56,8 +57,8 @@ class QueueBase extends events_1.EventEmitter {
56
57
  get client() {
57
58
  return this.connection.client;
58
59
  }
59
- setScripts() {
60
- this.scripts = new scripts_1.Scripts(this);
60
+ createScripts() {
61
+ this.scripts = (0, utils_1.createScripts)(this);
61
62
  }
62
63
  /**
63
64
  * Returns the version of the Redis instance the client is connected to,
@@ -5,11 +5,7 @@ exports.QueueGetters = void 0;
5
5
  const queue_base_1 = require("./queue-base");
6
6
  const utils_1 = require("../utils");
7
7
  /**
8
- *
9
- * @class QueueGetters
10
- * @extends QueueBase
11
- *
12
- * @description Provides different getters for different aspects of a queue.
8
+ * Provides different getters for different aspects of a queue.
13
9
  */
14
10
  class QueueGetters extends queue_base_1.QueueBase {
15
11
  getJob(jobId) {
@@ -95,10 +91,10 @@ class QueueGetters extends queue_base_1.QueueBase {
95
91
  /**
96
92
  * Job counts by type
97
93
  *
98
- * Queue#getJobCountByTypes('completed') => completed count
99
- * Queue#getJobCountByTypes('completed,failed') => completed + failed count
100
- * Queue#getJobCountByTypes('completed', 'failed') => completed + failed count
101
- * Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count
94
+ * Queue#getJobCountByTypes('completed') =\> completed count
95
+ * Queue#getJobCountByTypes('completed,failed') =\> completed + failed count
96
+ * Queue#getJobCountByTypes('completed', 'failed') =\> completed + failed count
97
+ * Queue#getJobCountByTypes('completed', 'waiting', 'failed') =\> completed + waiting + failed count
102
98
  */
103
99
  async getJobCountByTypes(...types) {
104
100
  const result = await this.getJobCounts(...types);
@@ -249,11 +245,12 @@ class QueueGetters extends queue_base_1.QueueBase {
249
245
  * A qualified job id is a string representing the job id in a given queue,
250
246
  * for example: "bull:myqueue:jobid".
251
247
  *
252
- * @param parentId The id of the parent job
253
- * @param type "processed" | "pending"
254
- * @param opts
248
+ * @param parentId - The id of the parent job
249
+ * @param type - "processed" | "pending"
250
+ * @param opts - Options for the query.
255
251
  *
256
- * @returns { items: { id: string, v?: any, err?: string } [], jobs: JobJsonRaw[], total: number}
252
+ * @returns an object with the following shape:
253
+ * `{ items: { id: string, v?: any, err?: string } [], jobs: JobJsonRaw[], total: number}`
257
254
  */
258
255
  async getDependencies(parentId, type, start, end) {
259
256
  const key = this.toKey(type == 'processed'
@@ -425,7 +422,7 @@ class QueueGetters extends queue_base_1.QueueBase {
425
422
  };
426
423
  }
427
424
  parseClientList(list, matcher) {
428
- const lines = list.split('\n');
425
+ const lines = list.split(/\r?\n/);
429
426
  const clients = [];
430
427
  lines.forEach((line) => {
431
428
  const client = {};
@@ -445,6 +442,29 @@ class QueueGetters extends queue_base_1.QueueBase {
445
442
  });
446
443
  return clients;
447
444
  }
445
+ /**
446
+ * Export the metrics for the queue in the Prometheus format.
447
+ * Automatically exports all the counts returned by getJobCounts().
448
+ *
449
+ * @returns - Returns a string with the metrics in the Prometheus format.
450
+ *
451
+ * @see {@link https://prometheus.io/docs/instrumenting/exposition_formats/}
452
+ *
453
+ **/
454
+ async exportPrometheusMetrics(globalVariables) {
455
+ const counts = await this.getJobCounts();
456
+ const metrics = [];
457
+ // Match the test's expected HELP text
458
+ metrics.push('# HELP bullmq_job_count Number of jobs in the queue by state');
459
+ metrics.push('# TYPE bullmq_job_count gauge');
460
+ const variables = !globalVariables
461
+ ? ''
462
+ : Object.keys(globalVariables).reduce((acc, curr) => `${acc}, ${curr}="${globalVariables[curr]}"`, '');
463
+ for (const [state, count] of Object.entries(counts)) {
464
+ metrics.push(`bullmq_job_count{queue="${this.name}", state="${state}"${variables}} ${count}`);
465
+ }
466
+ return metrics.join('\n');
467
+ }
448
468
  }
449
469
  exports.QueueGetters = QueueGetters;
450
470
  //# sourceMappingURL=queue-getters.js.map