mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
chore: Convert ErrorReporting to a Service to use DI. Add some tests (no-changelog) (#11279)
This commit is contained in:
committed by
GitHub
parent
5300e0ac45
commit
73145b70b8
@@ -6,13 +6,9 @@ import {
|
||||
InstanceSettings,
|
||||
ObjectStoreService,
|
||||
DataDeduplicationService,
|
||||
ErrorReporter,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
ApplicationError,
|
||||
ensureError,
|
||||
ErrorReporterProxy as ErrorReporter,
|
||||
sleep,
|
||||
} from 'n8n-workflow';
|
||||
import { ApplicationError, ensureError, sleep } from 'n8n-workflow';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import type { AbstractServer } from '@/abstract-server';
|
||||
@@ -22,7 +18,6 @@ import * as CrashJournal from '@/crash-journal';
|
||||
import * as Db from '@/db';
|
||||
import { getDataDeduplicationService } from '@/deduplication';
|
||||
import { DeprecationService } from '@/deprecation/deprecation.service';
|
||||
import { initErrorHandling } from '@/error-reporting';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay';
|
||||
import { initExpressionEvaluator } from '@/expression-evaluator';
|
||||
@@ -39,6 +34,8 @@ import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-hi
|
||||
export abstract class BaseCommand extends Command {
|
||||
protected logger = Container.get(Logger);
|
||||
|
||||
protected readonly errorReporter = Container.get(ErrorReporter);
|
||||
|
||||
protected externalHooks?: ExternalHooks;
|
||||
|
||||
protected nodeTypes: NodeTypes;
|
||||
@@ -63,7 +60,7 @@ export abstract class BaseCommand extends Command {
|
||||
protected needsCommunityPackages = false;
|
||||
|
||||
async init(): Promise<void> {
|
||||
await initErrorHandling();
|
||||
await this.errorReporter.init();
|
||||
initExpressionEvaluator();
|
||||
|
||||
process.once('SIGTERM', this.onTerminationSignal('SIGTERM'));
|
||||
@@ -130,7 +127,7 @@ export abstract class BaseCommand extends Command {
|
||||
}
|
||||
|
||||
protected async exitWithCrash(message: string, error: unknown) {
|
||||
ErrorReporter.error(new Error(message, { cause: error }), { level: 'fatal' });
|
||||
this.errorReporter.error(new Error(message, { cause: error }), { level: 'fatal' });
|
||||
await sleep(2000);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user