fix(plugin-workflow): fix dispatch bug (#2247)
This commit is contained in:
parent
67891d5721
commit
01db49a089
@ -216,7 +216,7 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private prepare = async () => {
|
private prepare = async () => {
|
||||||
const event = this.events.shift();
|
const [event] = this.events;
|
||||||
if (!event) {
|
if (!event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -276,6 +276,8 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.events.shift();
|
||||||
|
|
||||||
if (this.events.length) {
|
if (this.events.length) {
|
||||||
await this.prepare();
|
await this.prepare();
|
||||||
} else {
|
} else {
|
||||||
@ -303,6 +305,7 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
// resuming has high priority
|
// resuming has high priority
|
||||||
if (this.pending.length) {
|
if (this.pending.length) {
|
||||||
next = this.pending.shift() as Pending;
|
next = this.pending.shift() as Pending;
|
||||||
|
this.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
|
||||||
} else {
|
} else {
|
||||||
const execution = (await this.db.getRepository('executions').findOne({
|
const execution = (await this.db.getRepository('executions').findOne({
|
||||||
filter: {
|
filter: {
|
||||||
@ -312,13 +315,18 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
sort: 'createdAt',
|
sort: 'createdAt',
|
||||||
})) as ExecutionModel;
|
})) as ExecutionModel;
|
||||||
if (execution && execution.workflow.enabled) {
|
if (execution && execution.workflow.enabled) {
|
||||||
|
this.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
|
||||||
next = [execution];
|
next = [execution];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (next) {
|
if (next) {
|
||||||
this.process(...next);
|
await this.process(...next);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
this.executing = false;
|
this.executing = false;
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
this.dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,10 +347,6 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.getLogger(execution.workflowId).error(`execution (${execution.id}) error: ${err.message}`, err);
|
this.getLogger(execution.workflowId).error(`execution (${execution.id}) error: ${err.message}`, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.executing = false;
|
|
||||||
|
|
||||||
this.dispatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public createProcessor(execution: ExecutionModel, options = {}): Processor {
|
public createProcessor(execution: ExecutionModel, options = {}): Processor {
|
||||||
|
Loading…
Reference in New Issue
Block a user