fix: Upgrade bullmq and adjust to breaking changes in repeatable jobs (#8446)
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"bullmq": "^5.4.2",
|
"bullmq": "5.12.0",
|
||||||
"ioredis": "^5.2.5"
|
"ioredis": "^5.2.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"bullmq": "^5.4.2",
|
"bullmq": "5.12.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"ioredis": "^5.3.2",
|
"ioredis": "^5.3.2",
|
||||||
"knex": "2.4.2"
|
"knex": "2.4.2"
|
||||||
|
|||||||
@@ -374,10 +374,7 @@ export class RedisDistributedTransactionStorage
|
|||||||
const jobId =
|
const jobId =
|
||||||
typeof jobDefinition === "string" ? jobDefinition : jobDefinition.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
|
// If it is the same key (eg. the same workflow name), the old one will get overridden.
|
||||||
// any only then we add the new one.
|
|
||||||
await this.remove(jobId)
|
|
||||||
|
|
||||||
await this.queue.add(
|
await this.queue.add(
|
||||||
JobType.SCHEDULE,
|
JobType.SCHEDULE,
|
||||||
{
|
{
|
||||||
@@ -388,21 +385,14 @@ export class RedisDistributedTransactionStorage
|
|||||||
repeat: {
|
repeat: {
|
||||||
pattern: schedulerOptions.cron,
|
pattern: schedulerOptions.cron,
|
||||||
limit: schedulerOptions.numberOfExecutions,
|
limit: schedulerOptions.numberOfExecutions,
|
||||||
|
key: `${JobType.SCHEDULE}_${jobId}`,
|
||||||
},
|
},
|
||||||
jobId: `${JobType.SCHEDULE}_${jobId}`,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(jobId: string): Promise<void> {
|
async remove(jobId: string): Promise<void> {
|
||||||
const repeatableJobs = await this.queue.getRepeatableJobs()
|
await this.queue.removeRepeatableByKey(`${JobType.SCHEDULE}_${jobId}`)
|
||||||
const job = repeatableJobs.find(
|
|
||||||
(job) => job.id === `${JobType.SCHEDULE}_${jobId}`
|
|
||||||
)
|
|
||||||
|
|
||||||
if (job) {
|
|
||||||
await this.queue.removeRepeatableByKey(job.key)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeAll(): Promise<void> {
|
async removeAll(): Promise<void> {
|
||||||
|
|||||||
12
yarn.lock
12
yarn.lock
@@ -4543,7 +4543,7 @@ __metadata:
|
|||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
bullmq: ^5.4.2
|
bullmq: 5.12.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
ioredis: ^5.2.5
|
ioredis: ^5.2.5
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
@@ -5473,7 +5473,7 @@ __metadata:
|
|||||||
"@mikro-orm/migrations": 5.9.7
|
"@mikro-orm/migrations": 5.9.7
|
||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
bullmq: ^5.4.2
|
bullmq: 5.12.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
dotenv: ^16.4.5
|
||||||
ioredis: ^5.3.2
|
ioredis: ^5.3.2
|
||||||
@@ -14236,9 +14236,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"bullmq@npm:^5.4.2":
|
"bullmq@npm:5.12.0":
|
||||||
version: 5.7.8
|
version: 5.12.0
|
||||||
resolution: "bullmq@npm:5.7.8"
|
resolution: "bullmq@npm:5.12.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
cron-parser: ^4.6.0
|
cron-parser: ^4.6.0
|
||||||
ioredis: ^5.4.1
|
ioredis: ^5.4.1
|
||||||
@@ -14247,7 +14247,7 @@ __metadata:
|
|||||||
semver: ^7.5.4
|
semver: ^7.5.4
|
||||||
tslib: ^2.0.0
|
tslib: ^2.0.0
|
||||||
uuid: ^9.0.0
|
uuid: ^9.0.0
|
||||||
checksum: 49471348f6c645c58aa3105ab39a942f7537c0bbfdd3d4e9ba4c254eab941c0b3bb3301abe5dea0d19457b53661dbdb711566a34bb23d689b50bec111d9c1e98
|
checksum: ade12a22c16db021385bdfab826ab64488fcfb07274df1b6269bf513d073ea8e8a812b7308027a16df3f00feaf1d2afe79c8c7c86749b44794c2a2e89e34a411
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user