Skip to content

fix(node): Fix nest.js error handler #11874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2024
Merged

fix(node): Fix nest.js error handler #11874

merged 2 commits into from
May 2, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented May 2, 2024

This was brought up here #5578 (comment),

our error handler implementation was too naive, and our tests not ideal - the tests only checked that stuff is sent to sentry (which it was!) but not that the page otherwise worked.

Now, I updated the test to ensure this works as expected.

With this PR, the signature for Sentry.setupNestErrorHandler() changes ( breaking change, but sadly required at this point). You have to pass in an exception filter, which we'll extend to also send exceptions to Sentry:

import { BaseExceptionFilter, HttpAdapterHost } from '@nestjs/core';

const { httpAdapter } = app1.get(HttpAdapterHost);
Sentry.setupNestErrorHandler(app1, new BaseExceptionFilter(httpAdapter));

This is a bit more involved, but also allows you to use a custom filter if needed (we can extend any exception filter).

@mydea mydea self-assigned this May 2, 2024
@mydea mydea requested review from onurtemizkan, lforst and s1gr1d May 2, 2024 13:44
@mydea mydea enabled auto-merge (squash) May 2, 2024 14:32
@mydea mydea merged commit dc7b1f5 into develop May 2, 2024
82 checks passed
@mydea mydea deleted the fn/nestjs-fix branch May 2, 2024 14:36
Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants