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:
committed by
GitHub
parent
0edd4bcc87
commit
41cb0eec6e
@@ -15,6 +15,7 @@
|
||||
import { BinaryDataManager, IProcessMessage, WorkflowExecute } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ErrorReporterProxy as ErrorReporter,
|
||||
ExecutionError,
|
||||
IDeferredPromise,
|
||||
IExecuteResponsePromiseData,
|
||||
@@ -56,6 +57,7 @@ import * as Queue from './Queue';
|
||||
import { InternalHooksManager } from './InternalHooksManager';
|
||||
import { checkPermissionsForExecution } from './UserManagement/UserManagementHelper';
|
||||
import { generateFailedExecutionFromError } from './WorkflowHelpers';
|
||||
import { initErrorHandling } from './ErrorReporting';
|
||||
|
||||
export class WorkflowRunner {
|
||||
activeExecutions: ActiveExecutions.ActiveExecutions;
|
||||
@@ -76,6 +78,8 @@ export class WorkflowRunner {
|
||||
if (executionsMode === 'queue') {
|
||||
this.jobQueue = Queue.getInstance().getBullObjectInstance();
|
||||
}
|
||||
|
||||
initErrorHandling();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +102,8 @@ export class WorkflowRunner {
|
||||
executionId: string,
|
||||
hooks?: WorkflowHooks,
|
||||
) {
|
||||
ErrorReporter.error(error);
|
||||
|
||||
const fullRunData: IRun = {
|
||||
data: {
|
||||
resultData: {
|
||||
@@ -169,6 +175,7 @@ export class WorkflowRunner {
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
ErrorReporter.error(error);
|
||||
console.error('There was a problem running internal hook "onWorkflowPostExecute"', error);
|
||||
});
|
||||
|
||||
@@ -182,6 +189,7 @@ export class WorkflowRunner {
|
||||
]);
|
||||
})
|
||||
.catch((error) => {
|
||||
ErrorReporter.error(error);
|
||||
console.error('There was a problem running hook "workflow.postExecute"', error);
|
||||
});
|
||||
}
|
||||
@@ -263,6 +271,7 @@ export class WorkflowRunner {
|
||||
try {
|
||||
await checkPermissionsForExecution(workflow, data.userId);
|
||||
} catch (error) {
|
||||
ErrorReporter.error(error);
|
||||
// Create a failed execution with the data for the node
|
||||
// save it and abort execution
|
||||
const failedExecution = generateFailedExecutionFromError(
|
||||
@@ -503,6 +512,7 @@ export class WorkflowRunner {
|
||||
clearWatchdogInterval();
|
||||
}
|
||||
} catch (error) {
|
||||
ErrorReporter.error(error);
|
||||
// We use "getWorkflowHooksWorkerExecuter" as "getWorkflowHooksWorkerMain" does not contain the
|
||||
// "workflowExecuteAfter" which we require.
|
||||
const hooks = WorkflowExecuteAdditionalData.getWorkflowHooksWorkerExecuter(
|
||||
|
||||
Reference in New Issue
Block a user