mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Unify failed and error execution status (no-changelog) (#8943)
This commit is contained in:
@@ -865,7 +865,7 @@ async function executeWorkflow(
|
||||
mode: 'integrated',
|
||||
startedAt: new Date(),
|
||||
stoppedAt: new Date(),
|
||||
status: 'failed',
|
||||
status: 'error',
|
||||
};
|
||||
// When failing, we might not have finished the execution
|
||||
// Therefore, database might not contain finished errors.
|
||||
|
||||
@@ -61,7 +61,7 @@ export function generateFailedExecutionFromError(
|
||||
mode,
|
||||
startedAt: new Date(),
|
||||
stoppedAt: new Date(),
|
||||
status: 'failed',
|
||||
status: 'error',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@db/types';
|
||||
|
||||
export class RemoveFailedExecutionStatus1711018413374 implements IrreversibleMigration {
|
||||
async up({ escape, runQuery }: MigrationContext) {
|
||||
const executionEntity = escape.tableName('execution_entity');
|
||||
|
||||
await runQuery(`UPDATE ${executionEntity} SET status = 'error' WHERE status = 'failed';`);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import { AddWorkflowMetadata1695128658538 } from '../common/1695128658538-AddWor
|
||||
import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections';
|
||||
import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole';
|
||||
import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMapping';
|
||||
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
|
||||
|
||||
export const mysqlMigrations: Migration[] = [
|
||||
InitialMigration1588157391238,
|
||||
@@ -107,4 +108,5 @@ export const mysqlMigrations: Migration[] = [
|
||||
ModifyWorkflowHistoryNodesAndConnections1695829275184,
|
||||
AddGlobalAdminRole1700571993961,
|
||||
DropRoleMapping1705429061930,
|
||||
RemoveFailedExecutionStatus1711018413374,
|
||||
];
|
||||
|
||||
@@ -51,6 +51,7 @@ import { MigrateToTimestampTz1694091729095 } from './1694091729095-MigrateToTime
|
||||
import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections';
|
||||
import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole';
|
||||
import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMapping';
|
||||
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
|
||||
|
||||
export const postgresMigrations: Migration[] = [
|
||||
InitialMigration1587669153312,
|
||||
@@ -105,4 +106,5 @@ export const postgresMigrations: Migration[] = [
|
||||
ModifyWorkflowHistoryNodesAndConnections1695829275184,
|
||||
AddGlobalAdminRole1700571993961,
|
||||
DropRoleMapping1705429061930,
|
||||
RemoveFailedExecutionStatus1711018413374,
|
||||
];
|
||||
|
||||
@@ -49,6 +49,7 @@ import { AddWorkflowMetadata1695128658538 } from '../common/1695128658538-AddWor
|
||||
import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections';
|
||||
import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole';
|
||||
import { DropRoleMapping1705429061930 } from './1705429061930-DropRoleMapping';
|
||||
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
|
||||
|
||||
const sqliteMigrations: Migration[] = [
|
||||
InitialMigration1588102412422,
|
||||
@@ -101,6 +102,7 @@ const sqliteMigrations: Migration[] = [
|
||||
ModifyWorkflowHistoryNodesAndConnections1695829275184,
|
||||
AddGlobalAdminRole1700571993961,
|
||||
DropRoleMapping1705429061930,
|
||||
RemoveFailedExecutionStatus1711018413374,
|
||||
];
|
||||
|
||||
export { sqliteMigrations };
|
||||
|
||||
@@ -575,7 +575,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||
} else if (status === 'waiting') {
|
||||
condition.status = 'waiting';
|
||||
} else if (status === 'error') {
|
||||
condition.status = In(['error', 'crashed', 'failed']);
|
||||
condition.status = In(['error', 'crashed']);
|
||||
}
|
||||
|
||||
return condition;
|
||||
@@ -682,7 +682,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||
) {
|
||||
const where: FindOptionsWhere<ExecutionEntity> = {
|
||||
id: In(activeExecutionIds),
|
||||
status: Not(In(['finished', 'stopped', 'failed', 'crashed'] as ExecutionStatus[])),
|
||||
status: Not(In(['finished', 'stopped', 'error', 'crashed'])),
|
||||
};
|
||||
|
||||
if (filter) {
|
||||
|
||||
@@ -155,7 +155,7 @@ export class ExecutionDataRecoveryService {
|
||||
}
|
||||
|
||||
if (applyToDb) {
|
||||
const newStatus = executionEntry.status === 'failed' ? 'failed' : 'crashed';
|
||||
const newStatus = executionEntry.status === 'error' ? 'error' : 'crashed';
|
||||
await this.executionRepository.updateExistingExecution(executionId, {
|
||||
data: executionData,
|
||||
status: newStatus,
|
||||
|
||||
@@ -10,13 +10,13 @@ import { Logger } from '@/Logger';
|
||||
export function determineFinalExecutionStatus(runData: IRun): ExecutionStatus {
|
||||
const workflowHasCrashed = runData.status === 'crashed';
|
||||
const workflowWasCanceled = runData.status === 'canceled';
|
||||
const workflowHasFailed = runData.status === 'failed';
|
||||
const workflowHasFailed = runData.status === 'error';
|
||||
const workflowDidSucceed =
|
||||
!runData.data.resultData?.error &&
|
||||
!workflowHasCrashed &&
|
||||
!workflowWasCanceled &&
|
||||
!workflowHasFailed;
|
||||
let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
|
||||
let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'error';
|
||||
if (workflowHasCrashed) workflowStatusFinal = 'crashed';
|
||||
if (workflowWasCanceled) workflowStatusFinal = 'canceled';
|
||||
if (runData.waitTill) workflowStatusFinal = 'waiting';
|
||||
|
||||
@@ -13,7 +13,7 @@ export function getStatusUsingPreviousExecutionStatusMethod(
|
||||
} else if (execution.finished) {
|
||||
return 'success';
|
||||
} else if (execution.stoppedAt !== null) {
|
||||
return 'failed';
|
||||
return 'error';
|
||||
} else {
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user