fix: Upgrade bullmq and adjust to breaking changes in repeatable jobs (#8446)
This commit is contained in:
@@ -374,10 +374,7 @@ export class RedisDistributedTransactionStorage
|
||||
const jobId =
|
||||
typeof jobDefinition === "string" ? jobDefinition : jobDefinition.jobId
|
||||
|
||||
// In order to ensure that the schedule configuration is always up to date, we first cancel an existing job, if there was one
|
||||
// any only then we add the new one.
|
||||
await this.remove(jobId)
|
||||
|
||||
// If it is the same key (eg. the same workflow name), the old one will get overridden.
|
||||
await this.queue.add(
|
||||
JobType.SCHEDULE,
|
||||
{
|
||||
@@ -388,21 +385,14 @@ export class RedisDistributedTransactionStorage
|
||||
repeat: {
|
||||
pattern: schedulerOptions.cron,
|
||||
limit: schedulerOptions.numberOfExecutions,
|
||||
key: `${JobType.SCHEDULE}_${jobId}`,
|
||||
},
|
||||
jobId: `${JobType.SCHEDULE}_${jobId}`,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async remove(jobId: string): Promise<void> {
|
||||
const repeatableJobs = await this.queue.getRepeatableJobs()
|
||||
const job = repeatableJobs.find(
|
||||
(job) => job.id === `${JobType.SCHEDULE}_${jobId}`
|
||||
)
|
||||
|
||||
if (job) {
|
||||
await this.queue.removeRepeatableByKey(job.key)
|
||||
}
|
||||
await this.queue.removeRepeatableByKey(`${JobType.SCHEDULE}_${jobId}`)
|
||||
}
|
||||
|
||||
async removeAll(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user