fix(core): Fix execution cancellation in scaling mode (#9841)

This commit is contained in:
Iván Ovejero
2024-06-28 20:05:09 +02:00
committed by GitHub
parent 10f7d4b5b9
commit e613de28ca
10 changed files with 417 additions and 143 deletions

View File

@@ -22,6 +22,7 @@ import type {
import { parse, stringify } from 'flatted';
import {
ApplicationError,
WorkflowOperationError,
type ExecutionStatus,
type ExecutionSummary,
type IRunExecutionData,
@@ -609,8 +610,34 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
});
}
async cancel(executionId: string) {
await this.update({ id: executionId }, { status: 'canceled', stoppedAt: new Date() });
async stopBeforeRun(execution: IExecutionResponse) {
execution.status = 'canceled';
execution.stoppedAt = new Date();
await this.update(
{ id: execution.id },
{ status: execution.status, stoppedAt: execution.stoppedAt },
);
return execution;
}
async stopDuringRun(execution: IExecutionResponse) {
const error = new WorkflowOperationError('Workflow-Execution has been canceled!');
execution.data.resultData.error = {
...error,
message: error.message,
stack: error.stack,
};
execution.stoppedAt = new Date();
execution.waitTill = null;
execution.status = 'canceled';
await this.updateExistingExecution(execution.id, execution);
return execution;
}
async cancelMany(executionIds: string[]) {