feat(core): Run Error Workflow also on trigger activation error (#3470)

* feat(core): Run Error Workflow also when workflow gets deactivated
or could not be activated on startup because of error
R#

*  Add missing file
This commit is contained in:
Jan Oberhauser
2022-06-06 09:17:35 +02:00
committed by GitHub
parent ff95de0bdd
commit b5535e4a62
6 changed files with 97 additions and 27 deletions

View File

@@ -13,6 +13,7 @@
import { ActiveWorkflows, NodeExecuteFunctions } from 'n8n-core';
import {
ExecutionError,
IDeferredPromise,
IExecuteData,
IExecuteResponsePromiseData,
@@ -22,11 +23,13 @@ import {
INodeExecutionData,
IRun,
IRunExecutionData,
IWorkflowBase,
IWorkflowExecuteAdditionalData as IWorkflowExecuteAdditionalDataWorkflow,
NodeHelpers,
WebhookHttpMethod,
Workflow,
WorkflowActivateMode,
WorkflowActivationError,
WorkflowExecuteMode,
LoggerProxy as Logger,
} from 'n8n-workflow';
@@ -118,6 +121,7 @@ export class ActiveWorkflowRunner {
workflowName: workflowData.name,
workflowId: workflowData.id,
});
this.executeErrorWorkflow(error, workflowData, 'internal');
}
}
Logger.verbose('Finished initializing active workflows (startup)');
@@ -715,11 +719,39 @@ export class ActiveWorkflowRunner {
message: error.message,
},
};
const activationError = new WorkflowActivationError(
'There was a problem with the trigger, for that reason did the workflow had to be deactivated',
error,
node,
);
this.executeErrorWorkflow(activationError, workflowData, mode);
};
return returnFunctions;
};
}
executeErrorWorkflow(
error: ExecutionError,
workflowData: IWorkflowBase,
mode: WorkflowExecuteMode,
): void {
const fullRunData: IRun = {
data: {
resultData: {
error,
runData: {},
},
},
finished: false,
mode,
startedAt: new Date(),
stoppedAt: new Date(),
};
WorkflowExecuteAdditionalData.executeErrorWorkflow(workflowData, fullRunData, mode);
}
/**
* Makes a workflow active
*