Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2025-01-17 15:47:58 +00:00
commit 53afd48756

View File

@ -417,7 +417,7 @@ export default class PluginWorkflowServer extends Plugin {
} }
// NOTE: no await for quick return // NOTE: no await for quick return
setTimeout(this.prepare); setImmediate(this.prepare);
} }
private async triggerSync( private async triggerSync(
@ -463,6 +463,7 @@ export default class PluginWorkflowServer extends Plugin {
if (execution.status !== EXECUTION_STATUS.STARTED) { if (execution.status !== EXECUTION_STATUS.STARTED) {
return; return;
} }
this.getLogger(execution.workflowId).info(`starting deferred execution (${execution.id})`);
this.pending.push([execution]); this.pending.push([execution]);
if (this.executing) { if (this.executing) {
await this.executing; await this.executing;
@ -591,6 +592,10 @@ export default class PluginWorkflowServer extends Plugin {
if (this.events.length) { if (this.events.length) {
await this.prepare(); await this.prepare();
} else { } else {
this.getLogger('dispatcher').info('no more events need to be prepared, dispatching...');
if (this.executing) {
await this.executing;
}
this.dispatch(); this.dispatch();
} }
}; };
@ -656,7 +661,7 @@ export default class PluginWorkflowServer extends Plugin {
} }
this.executing = null; this.executing = null;
if (next) { if (next || this.pending.length) {
this.getLogger('dispatcher').info(`last process finished, will do another dispatch`); this.getLogger('dispatcher').info(`last process finished, will do another dispatch`);
this.dispatch(); this.dispatch();
} }
@ -668,11 +673,12 @@ export default class PluginWorkflowServer extends Plugin {
} }
private async process(execution: ExecutionModel, job?: JobModel, options: Transactionable = {}): Promise<Processor> { private async process(execution: ExecutionModel, job?: JobModel, options: Transactionable = {}): Promise<Processor> {
const logger = this.getLogger(execution.workflowId);
if (execution.status === EXECUTION_STATUS.QUEUEING) { if (execution.status === EXECUTION_STATUS.QUEUEING) {
const transaction = await this.useDataSourceTransaction('main', options.transaction); const transaction = await this.useDataSourceTransaction('main', options.transaction);
await execution.update({ status: EXECUTION_STATUS.STARTED }, { transaction }); await execution.update({ status: EXECUTION_STATUS.STARTED }, { transaction });
logger.info(`queueing execution (${execution.id}) from pending list updated to started`);
} }
const logger = this.getLogger(execution.workflowId);
const processor = this.createProcessor(execution, options); const processor = this.createProcessor(execution, options);
logger.info(`execution (${execution.id}) ${job ? 'resuming' : 'starting'}...`); logger.info(`execution (${execution.id}) ${job ? 'resuming' : 'starting'}...`);