mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Account for pre-execution failure in scaling mode (#12815)
This commit is contained in:
parent
36e615b28f
commit
b4d27c49e3
|
@ -1,6 +1,12 @@
|
||||||
import type { RunningJobSummary } from '@n8n/api-types';
|
import type { RunningJobSummary } from '@n8n/api-types';
|
||||||
import { Service } from '@n8n/di';
|
import { Service } from '@n8n/di';
|
||||||
import { InstanceSettings, WorkflowExecute, ErrorReporter, Logger } from 'n8n-core';
|
import {
|
||||||
|
WorkflowHasIssuesError,
|
||||||
|
InstanceSettings,
|
||||||
|
WorkflowExecute,
|
||||||
|
ErrorReporter,
|
||||||
|
Logger,
|
||||||
|
} from 'n8n-core';
|
||||||
import type {
|
import type {
|
||||||
ExecutionStatus,
|
ExecutionStatus,
|
||||||
IExecuteResponsePromiseData,
|
IExecuteResponsePromiseData,
|
||||||
|
@ -178,6 +184,7 @@ export class JobProcessor {
|
||||||
userId: manualData?.userId,
|
userId: manualData?.userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
workflowRun = this.manualExecutionService.runManually(
|
workflowRun = this.manualExecutionService.runManually(
|
||||||
data,
|
data,
|
||||||
workflow,
|
workflow,
|
||||||
|
@ -185,6 +192,25 @@ export class JobProcessor {
|
||||||
executionId,
|
executionId,
|
||||||
resultData.pinData,
|
resultData.pinData,
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof WorkflowHasIssuesError) {
|
||||||
|
// execution did not even start, but we call `workflowExecuteAfter` to notify main
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const runData: IRun = {
|
||||||
|
mode: 'manual',
|
||||||
|
status: 'error',
|
||||||
|
finished: false,
|
||||||
|
startedAt: now,
|
||||||
|
stoppedAt: now,
|
||||||
|
data: { resultData: { error, runData: {} } },
|
||||||
|
};
|
||||||
|
|
||||||
|
await additionalData.hooks.executeHookFunctions('workflowExecuteAfter', [runData]);
|
||||||
|
return { success: false };
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
} else if (execution.data !== undefined) {
|
} else if (execution.data !== undefined) {
|
||||||
workflowExecute = new WorkflowExecute(additionalData, execution.mode, execution.data);
|
workflowExecute = new WorkflowExecute(additionalData, execution.mode, execution.data);
|
||||||
workflowRun = workflowExecute.processRunExecutionData(workflow);
|
workflowRun = workflowExecute.processRunExecutionData(workflow);
|
||||||
|
|
7
packages/core/src/errors/workflow-has-issues.error.ts
Normal file
7
packages/core/src/errors/workflow-has-issues.error.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { WorkflowOperationError } from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class WorkflowHasIssuesError extends WorkflowOperationError {
|
||||||
|
constructor() {
|
||||||
|
super('The workflow has issues and cannot be executed for that reason. Please fix them first.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,7 +44,6 @@ import type {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import {
|
import {
|
||||||
LoggerProxy as Logger,
|
LoggerProxy as Logger,
|
||||||
WorkflowOperationError,
|
|
||||||
NodeHelpers,
|
NodeHelpers,
|
||||||
NodeConnectionType,
|
NodeConnectionType,
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
|
@ -56,6 +55,7 @@ import {
|
||||||
import PCancelable from 'p-cancelable';
|
import PCancelable from 'p-cancelable';
|
||||||
|
|
||||||
import { ErrorReporter } from '@/errors/error-reporter';
|
import { ErrorReporter } from '@/errors/error-reporter';
|
||||||
|
import { WorkflowHasIssuesError } from '@/errors/workflow-has-issues.error';
|
||||||
import * as NodeExecuteFunctions from '@/node-execute-functions';
|
import * as NodeExecuteFunctions from '@/node-execute-functions';
|
||||||
|
|
||||||
import { ExecuteContext, PollContext } from './node-execution-context';
|
import { ExecuteContext, PollContext } from './node-execution-context';
|
||||||
|
@ -1246,9 +1246,7 @@ export class WorkflowExecute {
|
||||||
pinDataNodeNames,
|
pinDataNodeNames,
|
||||||
});
|
});
|
||||||
if (workflowIssues !== null) {
|
if (workflowIssues !== null) {
|
||||||
throw new WorkflowOperationError(
|
throw new WorkflowHasIssuesError();
|
||||||
'The workflow has issues and cannot be executed for that reason. Please fix them first.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables which hold temporary data for each node-execution
|
// Variables which hold temporary data for each node-execution
|
||||||
|
|
|
@ -12,6 +12,7 @@ export * from './instance-settings';
|
||||||
export * from './logging';
|
export * from './logging';
|
||||||
export * from './nodes-loader';
|
export * from './nodes-loader';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
|
export { WorkflowHasIssuesError } from './errors/workflow-has-issues.error';
|
||||||
|
|
||||||
export * from './interfaces';
|
export * from './interfaces';
|
||||||
export * from './node-execute-functions';
|
export * from './node-execute-functions';
|
||||||
|
|
Loading…
Reference in a new issue