diff --git a/packages/core/src/errors/error-reporter.ts b/packages/core/src/errors/error-reporter.ts index e22749d3f2..40a6f8b5ae 100644 --- a/packages/core/src/errors/error-reporter.ts +++ b/packages/core/src/errors/error-reporter.ts @@ -4,7 +4,6 @@ import { Service } from '@n8n/di'; import type { ReportingOptions } from '@n8n/errors'; import type { ErrorEvent, EventHint } from '@sentry/core'; import type { NodeOptions } from '@sentry/node'; -import { eventLoopBlockIntegration } from '@sentry/node-native'; import { AxiosError } from 'axios'; import { ApplicationError, ExecutionCancelledError, BaseError } from 'n8n-workflow'; import { createHash } from 'node:crypto'; @@ -127,6 +126,8 @@ export class ErrorReporter { 'ContextLines', ]; + const eventLoopBlockIntegration = await this.getEventLoopBlockIntegration(); + init({ dsn, release, @@ -147,7 +148,7 @@ export class ErrorReporter { url: true, }, }), - eventLoopBlockIntegration(), + ...eventLoopBlockIntegration, ], }); @@ -253,4 +254,16 @@ export class ErrorReporter { if (extra) event.extra = { ...event.extra, ...extra }; if (tags) event.tags = { ...event.tags, ...tags }; } + + private async getEventLoopBlockIntegration() { + try { + const { eventLoopBlockIntegration } = await import('@sentry/node-native'); + return [eventLoopBlockIntegration()]; + } catch { + this.logger.debug( + "Sentry's event loop block integration is disabled, because the native binary for `@sentry/node-native` was not found", + ); + return []; + } + } }