chore: Convert ErrorReporting to a Service to use DI. Add some tests (no-changelog) (#11279)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-12-11 15:36:17 +01:00
committed by GitHub
parent 5300e0ac45
commit 73145b70b8
49 changed files with 443 additions and 386 deletions

View File

@@ -5,6 +5,7 @@
import * as a from 'assert/strict';
import {
DirectedGraph,
ErrorReporter,
InstanceSettings,
WorkflowExecute,
filterDisabledNodes,
@@ -22,11 +23,7 @@ import type {
IRunExecutionData,
IWorkflowExecuteAdditionalData,
} from 'n8n-workflow';
import {
ErrorReporterProxy as ErrorReporter,
ExecutionCancelledError,
Workflow,
} from 'n8n-workflow';
import { ExecutionCancelledError, Workflow } from 'n8n-workflow';
import PCancelable from 'p-cancelable';
import { Container, Service } from 'typedi';
@@ -55,6 +52,7 @@ export class WorkflowRunner {
constructor(
private readonly logger: Logger,
private readonly errorReporter: ErrorReporter,
private readonly activeExecutions: ActiveExecutions,
private readonly executionRepository: ExecutionRepository,
private readonly externalHooks: ExternalHooks,
@@ -82,7 +80,7 @@ export class WorkflowRunner {
return;
}
ErrorReporter.error(error, { executionId });
this.errorReporter.error(error, { executionId });
const isQueueMode = config.getEnv('executions.mode') === 'queue';
@@ -193,14 +191,14 @@ export class WorkflowRunner {
executionId,
]);
} catch (error) {
ErrorReporter.error(error);
this.errorReporter.error(error);
this.logger.error('There was a problem running hook "workflow.postExecute"', error);
}
}
})
.catch((error) => {
if (error instanceof ExecutionCancelledError) return;
ErrorReporter.error(error);
this.errorReporter.error(error);
this.logger.error(
'There was a problem running internal hook "onWorkflowPostExecute"',
error,