@@ -5,7 +5,7 @@ import {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { glob } from "glob"
|
import { glob } from "glob"
|
||||||
import logger from "../logger"
|
import logger from "../logger"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
export const registerJobs = async (plugins) => {
|
export const registerJobs = async (plugins) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@@ -50,8 +50,16 @@ const createJob = async ({ config, handler }) => {
|
|||||||
`${config.name}-as-step`,
|
`${config.name}-as-step`,
|
||||||
async (stepInput, stepContext) => {
|
async (stepInput, stepContext) => {
|
||||||
const { container } = stepContext
|
const { container } = stepContext
|
||||||
const res = await handler(container)
|
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||||
return new StepResponse(res, res)
|
try {
|
||||||
|
const res = await handler(container)
|
||||||
|
return new StepResponse(res, res)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
`Scheduled job ${config.name} failed with error: ${error.message}`
|
||||||
|
)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user