fix: test utils events + workflow storage (#12834)

* feat(test-utils): Make event subscriber waiter robust and concurrent

* feat(test-utils): Make event subscriber waiter robust and concurrent

* fix workflows storage

* remove timeout

* Create gentle-teachers-doubt.md

* revert timestamp

* update changeset

* fix execution loop

* exit if no steps to await

* typo

* check next

* check next

* changeset

* skip when async steps

* wait workflow executions utils

* wait workflow executions utils

* wait workflow executions utils

* increase timeout

* break loop

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2025-06-30 13:34:08 +02:00
1 parent 1e16fa6f57
commit 95d282e8ef
13 files changed
+441 -190

No files matched your search

@@ -841,6 +841,7 @@ export class TransactionOrchestrator extends EventEmitter {
const execution: Promise<void | unknown>[] = []
let i = 0
let hasAsyncSteps = false
for (const step of nextSteps.next) {
const stepIndex = i++
if (!stepsShouldContinueExecution[stepIndex]) {
@@ -876,12 +877,13 @@ export class TransactionOrchestrator extends EventEmitter {
} else {
// Execute async step in background and continue the execution of the transaction
this.executeAsyncStep(promise, transaction, step, nextSteps)
hasAsyncSteps = true
}
}
await promiseAll(execution)
if (nextSteps.next.length === 0) {
if (nextSteps.next.length === 0 || (hasAsyncSteps && !execution.length)) {
continueExecution = false
}
}
@@ -1290,6 +1292,16 @@ export class TransactionOrchestrator extends EventEmitter {
)
}
if (
flow.state === TransactionState.COMPENSATING ||
flow.state === TransactionState.WAITING_TO_COMPENSATE
) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
`Cannot revert a transaction that is already compensating.`
)
}
flow.state = TransactionState.WAITING_TO_COMPENSATE
flow.cancelledAt = Date.now()
File diff suppressed because it is too large. Load diff
@@ -80,6 +80,7 @@ const SPECIAL_PROPERTIES: {
nullable: false,
fieldName: field.fieldName,
defaultRaw: "now()",
onCreate: () => new Date(),
})(MikroORMEntity.prototype, field.fieldName)
},
updated_at: (MikroORMEntity, field) => {
@@ -89,6 +90,8 @@ const SPECIAL_PROPERTIES: {
nullable: false,
fieldName: field.fieldName,
defaultRaw: "now()",
onCreate: () => new Date(),
onUpdate: () => new Date(),
})(MikroORMEntity.prototype, field.fieldName)
},
deleted_at: (MikroORMEntity, field, tableName) => {