Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/modules/event-bus-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@medusajs/modules-sdk": "^1.12.11",
"@medusajs/utils": "^1.11.9",
"awilix": "^8.0.0",
"bullmq": "^5.4.2",
"bullmq": "5.12.0",
"ioredis": "^5.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/modules/workflow-engine-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"bullmq": "^5.4.2",
"bullmq": "5.12.0",
"dotenv": "^16.4.5",
"ioredis": "^5.3.2",
"knex": "2.4.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand All @@ -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> {
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4543,7 +4543,7 @@ __metadata:
"@medusajs/types": ^1.11.16
"@medusajs/utils": ^1.11.9
awilix: ^8.0.0
bullmq: ^5.4.2
bullmq: 5.12.0
cross-env: ^5.2.1
ioredis: ^5.2.5
jest: ^29.7.0
Expand Down Expand Up @@ -5473,7 +5473,7 @@ __metadata:
"@mikro-orm/migrations": 5.9.7
"@mikro-orm/postgresql": 5.9.7
awilix: ^8.0.0
bullmq: ^5.4.2
bullmq: 5.12.0
cross-env: ^5.2.1
dotenv: ^16.4.5
ioredis: ^5.3.2
Expand Down Expand Up @@ -14236,9 +14236,9 @@ __metadata:
languageName: node
linkType: hard

"bullmq@npm:^5.4.2":
version: 5.7.8
resolution: "bullmq@npm:5.7.8"
"bullmq@npm:5.12.0":
version: 5.12.0
resolution: "bullmq@npm:5.12.0"
dependencies:
cron-parser: ^4.6.0
ioredis: ^5.4.1
Expand All @@ -14247,7 +14247,7 @@ __metadata:
semver: ^7.5.4
tslib: ^2.0.0
uuid: ^9.0.0
checksum: 49471348f6c645c58aa3105ab39a942f7537c0bbfdd3d4e9ba4c254eab941c0b3bb3301abe5dea0d19457b53661dbdb711566a34bb23d689b50bec111d9c1e98
checksum: ade12a22c16db021385bdfab826ab64488fcfb07274df1b6269bf513d073ea8e8a812b7308027a16df3f00feaf1d2afe79c8c7c86749b44794c2a2e89e34a411
languageName: node
linkType: hard

Expand Down
Loading