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