Skip to content

Commit

Permalink
Handle promise exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi committed Nov 15, 2024
1 parent da1fd83 commit a5d38b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@n8n/task-runner/src/error-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() }),
Expand All @@ -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;
Expand Down

0 comments on commit a5d38b4

Please sign in to comment.