Skip to content

Nuxt 3.15.4 and Sentry Nuxt lead to Memory Leak #17555

@PhilippLupo

Description

@PhilippLupo

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

10.8.0

Framework Version

10.8.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

Package Lock Versions:

 "node_modules/nuxt": {
      "version": "3.15.4",
      "resolved": "https://registry.npmjs.org/nuxt/-/nuxt-3.15.4.tgz",
      "integrity": "sha512-hSbZO4mR0uAMJtZPNTnCfiAtgleoOu28gvJcBNU7KQHgWnNXPjlWgwMczko2O4Tmnv9zIe/CQged+2HsPwl2ZA==",
      "license": "MIT",
 "node_modules/@sentry/nuxt": {
      "version": "10.8.0",
      "resolved": "https://registry.npmjs.org/@sentry/nuxt/-/nuxt-10.8.0.tgz",
      "integrity": "sha512-GdxA7LiVn2EouI2PxNNmHUwtYUrECxDCdW4ARiSgEoKf3/bt8AP7Fi2RvOw2OGVv4Iwn2irDZtbFApsEQqkwSg==",
      "license": "MIT",
      "dependencies": {
        "@nuxt/kit": "^3.13.2",
        "@sentry/browser": "10.8.0",
        "@sentry/cloudflare": "10.8.0",
        "@sentry/core": "10.8.0",
        "@sentry/node": "10.8.0",
        "@sentry/rollup-plugin": "^4.1.1",
        "@sentry/vite-plugin": "^4.1.0",
        "@sentry/vue": "10.8.0"
      },
      "engines": {
        "node": ">=18.19.1"
      },
      "peerDependencies": {
        "nuxt": ">=3.7.0 || 4.x"
      }
    },

modules: [
    ....
    '@sentry/nuxt/module',
],
import * as Sentry from '@sentry/nuxt';
const env = useRuntimeConfig().public.APP_ENV;

Sentry.init({
  // If set up, you can use your runtime config here
  // dsn: useRuntimeConfig().public.sentry.dsn,
  dsn: 'https://....',

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: env === 'prod' ? 0.2 : 1.0,

  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // If the entire session is not sampled, use the below sample rate to sample
  // sessions when an error occurs.
  replaysOnErrorSampleRate: 1.0,

  // If you don't want to use Session Replay, just remove the line below:
  integrations: [Sentry.replayIntegration()],

  // Enable logs to be sent to Sentry
  enableLogs: true,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,

  environment: env,
});
import * as Sentry from '@sentry/nuxt';
import { config } from 'dotenv';

config();

const env = process.env.APP_ENV;

Sentry.init({
  dsn: 'https://.....',

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: env === 'prod' ? 0.2 : 1.0,

  // Enable logs to be sent to Sentry
  enableLogs: true,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,
  environment: env,
});

Steps to Reproduce

I have got a project that is currently running on Nuxt 3.15.4 and wanted to add Sentry.
Therefore I went to the official docs and went by installing it: https://nuxt.com/modules/sentry - nothing special.

Working locally in my DEV environment looks about fine, also the communication with Sentry and the dashboard all work fine.

As in the past I experienced some memory leaks with other Nuxt Modules i did the following:

  • npm run build
  • pm2-runtime .output/server/index.mjs
  • pm2 monit

Then I started my local loadtest by calling all possible url's and I saw the unusualy memory increase, which does not happen if sentry is not installed.

Expected Result

Without it's running pretty stable at around 300MB:

Image

Actual Result

After around 1-2 minutes my application uses already 2GB of memory with Nuxt Sentry (10.8.0) installed:

Image

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions