fix(medusa): stop loading entry points in exec command (#13438)

This commit is contained in:
William Bouchard
2025-09-09 14:10:56 -04:00
committed by GitHub
parent 0b55295fc7
commit e0943f3c90
5 changed files with 15 additions and 13 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
"fix(medusa): stop loading entry points in exec command

View File

@@ -91,7 +91,7 @@ async function populateData(api: any) {
) )
const products = response.data.created const products = response.data.created
await setTimeout(4000) await setTimeout(10000)
return products return products
} }

View File

@@ -1,9 +1,5 @@
import { ExecArgs } from "@medusajs/framework/types" import { ExecArgs } from "@medusajs/framework/types"
import { import { ContainerRegistrationKeys, dynamicImport, isFileSkipped, } from "@medusajs/framework/utils"
ContainerRegistrationKeys,
dynamicImport,
isFileSkipped,
} from "@medusajs/framework/utils"
import express from "express" import express from "express"
import { existsSync } from "fs" import { existsSync } from "fs"
import path from "path" import path from "path"
@@ -47,6 +43,7 @@ export default async function exec({ file, args }: Options) {
const { container } = await loaders({ const { container } = await loaders({
directory, directory,
expressApp: app, expressApp: app,
skipLoadingEntryPoints: true,
}) })
const scriptParams: ExecArgs = { const scriptParams: ExecArgs = {

View File

@@ -23,6 +23,7 @@ export default async function ({
const { container } = await loaders({ const { container } = await loaders({
directory, directory,
expressApp: app, expressApp: app,
skipLoadingEntryPoints: true,
}) })
const logger = container.resolve(ContainerRegistrationKeys.LOGGER) const logger = container.resolve(ContainerRegistrationKeys.LOGGER)

View File

@@ -33,6 +33,7 @@ import apiLoader from "./api"
type Options = { type Options = {
directory: string directory: string
expressApp: Express expressApp: Express
skipLoadingEntryPoints?: boolean
} }
const isWorkerMode = (configModule) => { const isWorkerMode = (configModule) => {
@@ -71,7 +72,7 @@ async function jobsLoader(
) { ) {
const pluginJobSourcePaths = [ const pluginJobSourcePaths = [
/** /**
* Load jobs from the medusa/medusa package. Remove once the medusa core is converted to a plugin * Load jobs from the medusa/medusa package. Remove once the medusa core is converted to a plugin
*/ */
join(__dirname, "../jobs"), join(__dirname, "../jobs"),
].concat(plugins.map((plugin) => join(plugin.resolve, "jobs"))) ].concat(plugins.map((plugin) => join(plugin.resolve, "jobs")))
@@ -161,6 +162,7 @@ export async function initializeContainer(
export default async ({ export default async ({
directory: rootDirectory, directory: rootDirectory,
expressApp, expressApp,
skipLoadingEntryPoints = false,
}: Options): Promise<{ }: Options): Promise<{
container: MedusaContainer container: MedusaContainer
app: Express app: Express
@@ -198,12 +200,9 @@ export default async ({
const workflowLoader = new WorkflowLoader(workflowsSourcePaths, container) const workflowLoader = new WorkflowLoader(workflowsSourcePaths, container)
await workflowLoader.load() await workflowLoader.load()
const entrypointsShutdown = await loadEntrypoints( const entrypointsShutdown = skipLoadingEntryPoints
plugins, ? () => {}
container, : await loadEntrypoints(plugins, container, expressApp, rootDirectory)
expressApp,
rootDirectory
)
const { createDefaultsWorkflow } = await import("@medusajs/core-flows") const { createDefaultsWorkflow } = await import("@medusajs/core-flows")
await createDefaultsWorkflow(container).run() await createDefaultsWorkflow(container).run()