sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Nestjs integration reports 404 errors to sentry

Open strongpauly opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.9.2

Framework Version

No response

Link to Sentry event

https://zero1.sentry.io/issues/5500224353/events/?alert_rule_id=11637924&alert_type=issue&notification_uuid=5695e46f-daeb-45f7-b17a-c7b757adad3c&project=6391861&referrer=slack

SDK Setup

Sentry.init({
        dsn: dsn,
        attachStacktrace: true,
        release: release,
        environment: enviroment,
        serverName: serverName
})

Steps to Reproduce

  1. Bootstrap app as described in the documentation:
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const { httpAdapter } = app.get(HttpAdapterHost);

  Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));

  await app.listen(3000);
}
  1. Send a request to the server which results in a NotFoundException or 404

Expected Result

Server should respond with a 404 error and this error should not be sent to Sentry as its expected behaviour.

Actual Result

Event is reported and devs get a notification causing noise.

strongpauly avatar Jun 18 '24 10:06 strongpauly

Hey, thanks for reporting this. We should ignore 4xx errors by default, you are right! We'll look into this. For now, you can filter them via the SDk, using beforeSend or ignore errors - see https://docs.sentry.io/platforms/javascript/guides/nestjs/configuration/filtering/

mydea avatar Jun 18 '24 10:06 mydea