fix(plugin-workflow): fix sync collection trigger transaction (#3437)

This commit is contained in:
Junyi 2024-01-26 11:08:45 +08:00 committed by GitHub
parent d692d9cf1b
commit dada993d80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,17 +85,23 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
// TODO: `result.toJSON()` throws error // TODO: `result.toJSON()` throws error
const json = toJSON(result); const json = toJSON(result);
const promise = this.workflow.trigger(
workflow,
{ data: json },
{
context,
transaction,
},
);
if (workflow.sync) { if (workflow.sync) {
await promise; await this.workflow.trigger(
workflow,
{ data: json },
{
context,
transaction,
},
);
} else {
this.workflow.trigger(
workflow,
{ data: json },
{
context,
},
);
} }
} }