fix(orchestrator): inject only if it has decorator (#6666)

This commit is contained in:
Carlos R. L. Rodrigues
2024-03-12 04:11:33 -03:00
committed by GitHub
parent d48c076b77
commit a8794d48de
2 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/orchestration": patch
---
Inject context only if method use decorator @MedusaContext

View File

@@ -4,6 +4,7 @@ import {
MedusaContextType,
MedusaModuleType,
createMedusaContainer,
isDefined,
} from "@medusajs/utils"
import { asValue } from "awilix"
import {
@@ -90,11 +91,10 @@ export class LocalWorkflow {
}
return async (...args) => {
const ctxIndex =
MedusaContext.getIndex(target, prop as string) ?? args.length - 1
const ctxIndex = MedusaContext.getIndex(target, prop as string)
const hasContext = args[ctxIndex]?.__type === MedusaContextType
if (!hasContext) {
const hasContext = args[ctxIndex!]?.__type === MedusaContextType
if (!hasContext && isDefined(ctxIndex)) {
const context = this_.medusaContext
if (context?.__type === MedusaContextType) {
delete context?.manager