feat(API): Set up error tracking using Sentry (#4394)

* feat(cli): Setup error tracking using Sentry

* make error reporting available in the workflows package

* address some of the PR comments

* create a ErrorReporterProxy like LoggerProxy

* remove the `captureError` helper. use ErrorReporterProxy directly

* fix linting issues

* remove ErrorReporterProxy warnings in tests

* check for NODE_ENV === 'production' instead

* IErrorReporter -> ErrorReporter

* ErrorReporterProxy.getInstance() -> ErrorReporter

* allow capturing stacks in warnings as well

* make n8n debugging consistent with `npm start`

* IReportingOptions -> ReportingOptions

* use consistent signature for `error` and `warn`

* use Logger instead of console.log
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-04 17:34:47 +01:00
committed by GitHub
parent 0edd4bcc87
commit 41cb0eec6e
27 changed files with 15097 additions and 8015 deletions

View File

@@ -9,6 +9,7 @@
import { BinaryDataManager, IProcessMessage, UserSettings, WorkflowExecute } from 'n8n-core';
import {
ErrorReporterProxy as ErrorReporter,
ExecutionError,
ICredentialType,
ICredentialTypeData,
@@ -52,6 +53,7 @@ import { InternalHooksManager } from './InternalHooksManager';
import { checkPermissionsForExecution } from './UserManagement/UserManagementHelper';
import { loadClassInIsolation } from './CommunityNodes/helpers';
import { generateFailedExecutionFromError } from './WorkflowHelpers';
import { initErrorHandling } from './ErrorReporting';
export class WorkflowRunnerProcess {
data: IWorkflowExecutionDataProcessWithExecution | undefined;
@@ -79,6 +81,10 @@ export class WorkflowRunnerProcess {
}, 30000);
}
constructor() {
initErrorHandling();
}
async runWorkflow(inputData: IWorkflowExecutionDataProcessWithExecution): Promise<IRun> {
process.on('SIGTERM', WorkflowRunnerProcess.stopProcess);
process.on('SIGINT', WorkflowRunnerProcess.stopProcess);
@@ -265,6 +271,7 @@ export class WorkflowRunnerProcess {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
await sendToParentProcess('sendMessageToUI', { source, message });
} catch (error) {
ErrorReporter.error(error);
this.logger.error(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
`There was a problem sending UI data to parent process: "${error.message}"`,
@@ -402,6 +409,7 @@ export class WorkflowRunnerProcess {
parameters,
});
} catch (error) {
ErrorReporter.error(error);
this.logger.error(`There was a problem sending hook: "${hook}"`, { parameters, error });
}
}