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,7 +85,8 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
// TODO: `result.toJSON()` throws error
const json = toJSON(result);
const promise = this.workflow.trigger(
if (workflow.sync) {
await this.workflow.trigger(
workflow,
{ data: json },
{
@ -93,9 +94,14 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
transaction,
},
);
if (workflow.sync) {
await promise;
} else {
this.workflow.trigger(
workflow,
{ data: json },
{
context,
},
);
}
}