fix(core): Fix Sentry error reporting on task runners (#12495)

This commit is contained in:
Iván Ovejero
2025-01-08 17:47:40 +01:00
committed by GitHub
parent dd36bb28bf
commit 88c0838dd7
7 changed files with 62 additions and 19 deletions

View File

@@ -2,9 +2,9 @@ import { Config, Env } from '@n8n/config';
@Config
export class SentryConfig {
/** Sentry DSN */
/** Sentry DSN (data source name) */
@Env('N8N_SENTRY_DSN')
sentryDsn: string = '';
dsn: string = '';
//#region Metadata about the environment

View File

@@ -50,7 +50,7 @@ describe('JsTaskRunner', () => {
...jsRunnerOpts,
},
sentryConfig: {
sentryDsn: '',
dsn: '',
deploymentName: '',
environment: '',
n8nVersion: '',

View File

@@ -54,10 +54,19 @@ void (async function start() {
defaultTimezone: config.baseRunnerConfig.timezone,
});
if (config.sentryConfig.sentryDsn) {
const { dsn } = config.sentryConfig;
if (dsn) {
const { ErrorReporter } = await import('n8n-core');
errorReporter = Container.get(ErrorReporter);
await errorReporter.init('task_runner', config.sentryConfig.sentryDsn);
const { deploymentName, environment, n8nVersion } = config.sentryConfig;
await errorReporter.init({
serverType: 'task_runner',
dsn,
serverName: deploymentName,
environment,
release: n8nVersion,
});
}
runner = new JsTaskRunner(config);