fix: Upgrade bullmq and adjust to breaking changes in repeatable jobs (#8446)

This commit is contained in:
Stevche Radevski
2024-08-05 13:00:27 +02:00
committed by GitHub
parent 2682e2e324
commit 5c09f0813d
4 changed files with 11 additions and 21 deletions

View File

@@ -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> {