From dada993d8000e77c36f01f1a1268bf1c2467fd31 Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 26 Jan 2024 11:08:45 +0800 Subject: [PATCH] fix(plugin-workflow): fix sync collection trigger transaction (#3437) --- .../src/server/triggers/CollectionTrigger.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-workflow/src/server/triggers/CollectionTrigger.ts b/packages/plugins/@nocobase/plugin-workflow/src/server/triggers/CollectionTrigger.ts index bbeb82313..1faa2a0bc 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/server/triggers/CollectionTrigger.ts +++ b/packages/plugins/@nocobase/plugin-workflow/src/server/triggers/CollectionTrigger.ts @@ -85,17 +85,23 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M // TODO: `result.toJSON()` throws error const json = toJSON(result); - const promise = this.workflow.trigger( - workflow, - { data: json }, - { - context, - transaction, - }, - ); - if (workflow.sync) { - await promise; + await this.workflow.trigger( + workflow, + { data: json }, + { + context, + transaction, + }, + ); + } else { + this.workflow.trigger( + workflow, + { data: json }, + { + context, + }, + ); } }