fix(medusa): Fix regression in job scheduler service (#3335)
The queue registration of jobs has stopped working due to a small issue in how the jobs are added to the queue. Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
1 parent
89ed4cd2b1
commit
370bd472ed
3 files changed
+16
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): Fix regression in job scheduler service
|
||||||
@@ -53,6 +53,15 @@ describe("JobSchedulerService", () => {
|
|||||||
|
|
||||||
it("added the handler to the job queue", () => {
|
it("added the handler to the job queue", () => {
|
||||||
expect(jobScheduler.handlers_.get("eventName").length).toEqual(1)
|
expect(jobScheduler.handlers_.get("eventName").length).toEqual(1)
|
||||||
|
expect(jobScheduler.queue_.add).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
eventName: "eventName",
|
||||||
|
data: { data: "test" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repeat: { cron: "* * * * *" },
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export default class JobSchedulerService {
|
|||||||
const repeatOpts = { repeat: { cron: schedule } }
|
const repeatOpts = { repeat: { cron: schedule } }
|
||||||
|
|
||||||
if (options?.keepExisting) {
|
if (options?.keepExisting) {
|
||||||
return await this.queue_.add(eventName, jobToCreate, repeatOpts)
|
return await this.queue_.add(jobToCreate, repeatOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingJobs = (await this.queue_.getRepeatableJobs()) ?? []
|
const existingJobs = (await this.queue_.getRepeatableJobs()) ?? []
|
||||||
@@ -134,6 +134,6 @@ export default class JobSchedulerService {
|
|||||||
await this.queue_.removeRepeatableByKey(existingJob.key)
|
await this.queue_.removeRepeatableByKey(existingJob.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.queue_.add(eventName, jobToCreate, repeatOpts)
|
return await this.queue_.add(jobToCreate, repeatOpts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user