fix(plugin-workflow): fix transaction in trigger (#1186)

This commit is contained in:
Junyi 2022-12-02 02:15:53 -08:00 committed by GitHub
parent dd91aee89d
commit eb4fb29e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,10 +152,7 @@ export default class WorkflowPlugin extends Plugin {
} }
} }
// @ts-ignore const transaction = await (<typeof WorkflowModel>workflow.constructor).database.sequelize.transaction();
const transaction = options.transaction && !options.transaction.finished
? options.transaction
: await (<typeof WorkflowModel>workflow.constructor).database.sequelize.transaction();
const execution = await workflow.createExecution({ const execution = await workflow.createExecution({
context, context,
@ -189,10 +186,7 @@ export default class WorkflowPlugin extends Plugin {
execution.workflow = workflow; execution.workflow = workflow;
// @ts-ignore await transaction.commit();
if (transaction && (!options.transaction || options.transaction.finished)) {
await transaction.commit();
}
setTimeout(() => this.dispatch(execution)); setTimeout(() => this.dispatch(execution));
} }