fix(plugin-workflow): fix events in prepare (#1325)
This commit is contained in:
parent
fb8a4de8cc
commit
8943dabc4d
@ -158,7 +158,11 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private prepare = async () => {
|
private prepare = async () => {
|
||||||
const [workflow, context, options] = this.events[0];
|
const event = this.events.shift();
|
||||||
|
if (!event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [workflow, context, options] = event;
|
||||||
|
|
||||||
if (options.context?.executionId) {
|
if (options.context?.executionId) {
|
||||||
// NOTE: no transaction here for read-uncommitted execution
|
// NOTE: no transaction here for read-uncommitted execution
|
||||||
@ -213,8 +217,6 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
this.pending.push([execution]);
|
this.pending.push([execution]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.events.shift();
|
|
||||||
|
|
||||||
if (this.events.length) {
|
if (this.events.length) {
|
||||||
await this.prepare();
|
await this.prepare();
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,6 +215,17 @@ describe('workflow > Plugin', () => {
|
|||||||
|
|
||||||
const [execution] = await workflow.getExecutions();
|
const [execution] = await workflow.getExecutions();
|
||||||
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||||
|
|
||||||
|
// NOTE: second trigger to ensure no skipped event
|
||||||
|
const p3 = await PostRepo.create({ values: { title: 't2' } });
|
||||||
|
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
|
const posts2 = await PostRepo.find();
|
||||||
|
expect(posts2.length).toBe(4);
|
||||||
|
|
||||||
|
const [execution2] = await workflow.getExecutions({ order: [['createdAt', 'DESC']] });
|
||||||
|
expect(execution2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user