fix(cli): Fix issue with n8n crashing when error in poll method (#4008)

* 🐛 Fix issue with n8n crashing when error in poll method

* Remove unnecessary imports and add async property

* Remove unnecessary imports

*  Move createErrorExecution to genericHelper

*  Improvements

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
Ricardo Espinoza
2022-09-15 16:16:54 -04:00
committed by GitHub
parent 07672cce7d
commit 6c41b29ad2
4 changed files with 126 additions and 11 deletions

View File

@@ -57,6 +57,7 @@ import { User } from './databases/entities/User';
import { whereClause } from './WorkflowHelpers';
import { WorkflowEntity } from './databases/entities/WorkflowEntity';
import * as ActiveExecutions from './ActiveExecutions';
import { createErrorExecution } from './GenericHelpers';
const activeExecutions = ActiveExecutions.getInstance();
@@ -650,7 +651,14 @@ export class ActiveWorkflowRunner {
activation,
);
// eslint-disable-next-line no-underscore-dangle
returnFunctions.__emit = (data: INodeExecutionData[][]): void => {
returnFunctions.__emit = async (
data: INodeExecutionData[][] | ExecutionError,
): Promise<void> => {
if (data instanceof Error) {
await createErrorExecution(data, node, workflowData, workflow, mode);
this.executeErrorWorkflow(data, workflowData, mode);
return;
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.debug(`Received event to trigger execution for workflow "${workflow.name}"`);
WorkflowHelpers.saveStaticData(workflow);