Skip to content

@sentry/nestjs graphql crashes the application on 404 #14314

@jhmen

Description

@jhmen

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.38.0

Framework Version

nestjs 10.4.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

instrument.ts:

import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import * as process from 'node:process';

Sentry.init({
  // We cant use the config service here, because we need to initialize Sentry before the app starts
  dsn: process.env.SENTRY_DSN,
  integrations: [nodeProfilingIntegration()],
  // Tracing
  tracesSampleRate: +process.env.SENTRY_TRACES_SAMPLE_RATE || 0.1, //  Capture 100% of the transactions

  // Set sampling rate for profiling - this is relative to tracesSampleRate
  profilesSampleRate: +process.env.PROFILES_SAMPLE_RATE || 0.1,

  environment: process.env.SENTRY_ENVIRONMENT,
});

app.module.ts:

@Module({
  imports: [
    SentryModule.forRoot(),
  ],
  providers: [
    {
      provide: APP_FILTER,
      useClass: SentryGlobalGraphQLFilter,
    },
  ],
})

Steps to Reproduce

  1. Create a nestjs + graphql application
  2. Install sentry
  3. Setup sentry like it is shown in the docs
  4. Start the application
  5. Call a url like /fav.ico which does not exist
  6. The application crashes

Expected Result

The application should not crash

Actual Result

The application crashes. It does not exit, but no request can be made, and the application is not responding.

2024-11-15T06:30:28.009579112Z [2024-11-15T06:30:28.007Z] ERROR    NotFoundException: Cannot GET /favicon.ico
2024-11-15T06:30:28.009619610Z     at callback (/usr/src/<application>/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_refl_gwypgs4obw5tw3bpishsnyaznu/node_modules/@nestjs/core/router/routes-resolver.js:77:19)
2024-11-15T06:30:28.009623899Z     at /usr/src/<application>/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_refl_gwypgs4obw5tw3bpishsnyaznu/node_modules/@nestjs/core/router/router-proxy.js:9:23
2024-11-15T06:30:28.009627495Z     at Layer.handle [as handle_request] (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
2024-11-15T06:30:28.009630892Z     at trim_prefix (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)
2024-11-15T06:30:28.009634259Z     at /usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9
2024-11-15T06:30:28.009637755Z     at Function.process_params (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)
2024-11-15T06:30:28.009640951Z     at next (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)
2024-11-15T06:30:28.009643907Z     at urlencodedParser (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/types/urlencoded.js:91:7)
2024-11-15T06:30:28.009647093Z     at Layer.handle [as handle_request] (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
2024-11-15T06:30:28.009650209Z     at trim_prefix (/usr/src/<application>/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nestjsIssues related to the Sentry Nestjs SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions