From 9b8f9ea30b7b7c5f6c325b58519342b0741d7667 Mon Sep 17 00:00:00 2001 From: Andrei <168741329+andreiborza@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:10:15 +0200 Subject: [PATCH] fix(nestjs): Ensure exception and host are correctly passed on when using @WithSentry (#13564) Also adds the `nestjs-with-submodules-decorator` e2e test app to be run on CI. --- .github/workflows/build.yml | 1 + packages/nestjs/src/decorators/with-sentry.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 539f2537fc78..4f06228f3a7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -908,6 +908,7 @@ jobs: 'nestjs-basic', 'nestjs-distributed-tracing', 'nestjs-with-submodules', + 'nestjs-with-submodules-decorator', 'nestjs-graphql', 'node-exports-test-app', 'node-koa', diff --git a/packages/nestjs/src/decorators/with-sentry.ts b/packages/nestjs/src/decorators/with-sentry.ts index 6b02d73a94c8..cf86ea6e7cc5 100644 --- a/packages/nestjs/src/decorators/with-sentry.ts +++ b/packages/nestjs/src/decorators/with-sentry.ts @@ -12,11 +12,11 @@ export function WithSentry() { // eslint-disable-next-line @typescript-eslint/no-explicit-any descriptor.value = function (exception: unknown, host: unknown, ...args: any[]) { if (isExpectedError(exception)) { - return originalCatch.apply(this, args); + return originalCatch.apply(this, [exception, host, ...args]); } captureException(exception); - return originalCatch.apply(this, args); + return originalCatch.apply(this, [exception, host, ...args]); }; return descriptor;