From a5d38b4fd03a02ab51eeb508adab8d2b29313c1e Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:48:47 +0200 Subject: [PATCH] Handle promise exceptions --- packages/@n8n/task-runner/src/error-reporter.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@n8n/task-runner/src/error-reporter.ts b/packages/@n8n/task-runner/src/error-reporter.ts index 8a47fcd27f5fa..167cc37c924b1 100644 --- a/packages/@n8n/task-runner/src/error-reporter.ts +++ b/packages/@n8n/task-runner/src/error-reporter.ts @@ -49,7 +49,7 @@ export class ErrorReporter { enableTracing: false, serverName: this.sentryConfig.deploymentName, beforeBreadcrumb: () => null, - beforeSend: (event, hint) => this.beforeSend(event, hint), + beforeSend: async (event, hint) => await this.beforeSend(event, hint), integrations: (integrations) => [ ...integrations.filter(({ name }) => ENABLED_INTEGRATIONS.includes(name)), new RewriteFrames({ root: process.cwd() }), @@ -67,9 +67,13 @@ export class ErrorReporter { await close(1000); } - beforeSend(event: ErrorEvent, { originalException }: EventHint) { + async beforeSend(event: ErrorEvent, { originalException }: EventHint) { if (!originalException) return null; + if (originalException instanceof Promise) { + originalException = await originalException.catch((error) => error as Error); + } + if (originalException instanceof ApplicationError) { const { level, extra, tags } = originalException; if (level === 'warning') return null;