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:
pepijn-vanvlaanderen
2023-02-28 08:53:51 +01:00
committed by GitHub
parent 89ed4cd2b1
commit 370bd472ed
3 changed files with 16 additions and 2 deletions
+5
View File
@@ -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", () => {
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 } }
if (options?.keepExisting) {
return await this.queue_.add(eventName, jobToCreate, repeatOpts)
return await this.queue_.add(jobToCreate, repeatOpts)
}
const existingJobs = (await this.queue_.getRepeatableJobs()) ?? []
@@ -134,6 +134,6 @@ export default class JobSchedulerService {
await this.queue_.removeRepeatableByKey(existingJob.key)
}
return await this.queue_.add(eventName, jobToCreate, repeatOpts)
return await this.queue_.add(jobToCreate, repeatOpts)
}
}