fix(orchestration, workflow-sdk): Local workflow separated orchestrator (#8765)

FIXES TRI-174

**What**
Currently, every time a Local workflow is being instantiated, it will grab the global workflow definition including the orchestrator instance. This leads to issues when we have concurrent running workflows which all register their event listeners to this single orchestrator instance which can lead to exhausting the listerners. 
With this fix, every local workflow will have a copy of the global workflow definition plus a new instance (cloned) of the orchestrator meaning that from now on, every local workflow will have its own orchestrator.
This commit is contained in:
Adrien de Peretti
2024-08-27 10:59:56 +02:00
committed by GitHub
parent 59217a9796
commit b09c19912b
5 changed files with 141 additions and 54 deletions

View File

@@ -9,9 +9,9 @@ import {
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
import {
ContainerRegistrationKeys,
isPresent,
MedusaContextType,
ModuleRegistrationName,
isPresent,
} from "@medusajs/utils"
import { EOL } from "os"
import { ulid } from "ulid"
@@ -518,12 +518,12 @@ function attachOnFinishReleaseEvents(
const TERMINAL_SIZE = process.stdout?.columns ?? 60
const separator = new Array(TERMINAL_SIZE).join("-")
const worflowName = transaction.getFlow().modelId
const workflowName = transaction.getFlow().modelId
const allWorkflowErrors = transaction
.getErrors()
.map(
(err) =>
`${worflowName}:${err?.action}:${err?.handlerType} - ${err?.error?.message}${EOL}${err?.error?.stack}`
`${workflowName}:${err?.action}:${err?.handlerType} - ${err?.error?.message}${EOL}${err?.error?.stack}`
)
.join(EOL + separator + EOL)