Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.36.0
Framework Version
Node 19.9.0, also tested on Node 20.18.0
Link to Sentry event
N/A
Reproduction Example/SDK Setup
import*asSentryfrom"@sentry/node"importapifrom"@opentelemetry/api"functiontrimData(data){constsize=JSON.stringify(data||"").length// Arbitrarily cut off massive payloads. Sentry silently drops events that are too large,// so trim them.// See https://github.com/getsentry/sentry-javascript/issues/3036#issuecomment-1066491190if(size>200000){returndata?.slice(0,200000)}returndata}functioncheckIfSentryIgnore(url){if(!url)returnfalsefor(constrouteofSENTRY_IGNORED_ROUTES){if(typeofroute==="string"&&url.endsWith(route)){returntrue}elseif(routeinstanceofRegExp&&route.test(url)){returntrue}}}/** * Need to ignore long-running websockets. * * See: https://github.com/getsentry/sentry-javascript/issues/13412#issuecomment-2340434248 */constIGNORE_WEBSOCKETS=["infura","ws","alchemy","ankr","zora"]Sentry.init({dsn: "snip",// Disable entirely on non-production environments.enabled: true,debug: !!process.env.SENTRY_DEBUGGING,registerEsmLoaderHooks: {exclude: [/openai/]},includeLocalVariables: true,integrations: [Sentry.onUncaughtExceptionIntegration({exitEvenIfOtherHandlersAreRegistered: false,}),Sentry.expressIntegration(),Sentry.httpIntegration({ignoreOutgoingRequests(url,request){console.log("SENTRY: should we ignore outgoing request?",url)for(constrouteofIGNORE_WEBSOCKETS){if(url.includes(route)){console.log("SENTRY: Ignoring outgoing request",url)returntrue}}console.log("SENTRY: Not ignoring outgoing request",url)returnfalse},}),],release: process.env.COMMIT,environment: process.env.FLY_APP_NAME||"development",beforeSendTransaction(event){console.log("SENTRY: beforeSendTransaction",event)if(event.transaction==="redis-connect"){// Don't send the event to Sentryreturnnull}console.log("SENTRY: Sending transaction",event)returnevent},beforeSend: (event)=>{console.log("SENTRY: beforeSend",event)try{if(event.request?.data){event.request.data=trimData(event.request.data)}if(event.message){event.message=trimData(event.message)}returnevent}catch(e){console.error("Error in Sentry beforeSend",e,event)returnevent}},})Steps to Reproduce
Run Node 19 or Node 20 with Sentry enabled in my specific setup. The memory gradually increases until an OOM occurs.
This graph shows when Node was updated from 18 to 19.9.0. No other code changes occurred.

Expected Result
Memory does not gradually increase until an OOM occurs.
This graph shows when I disabled includeLocalVariables in the above Sentry.init: memory stops increasing.

Actual Result
Memory increases gradually until it OOMs, if includeLocalVariables is enabled.
If Sentry is disabled entirely, or if the includeLocalVariables flag is disabled, then memory looks as expected.
I originally suspected this was the issue, since we also use websockets and long-running requests, but after ignoring the requests and confirming via the console.logs that none of the long-running requests got spans created (with the issue still persisting), I tried disabling local variables and that fixed it.
These are (truncated) logs with trace GC enabled. It's not particularly showing much other than memory growth. This shows with local variables enabled, and this is with it disabled.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.36.0
Framework Version
Node 19.9.0, also tested on Node 20.18.0
Link to Sentry event
N/A
Reproduction Example/SDK Setup
Steps to Reproduce
Run Node 19 or Node 20 with Sentry enabled in my specific setup. The memory gradually increases until an OOM occurs.
This graph shows when Node was updated from 18 to 19.9.0. No other code changes occurred.

Expected Result
Memory does not gradually increase until an OOM occurs.
This graph shows when I disabled includeLocalVariables in the above Sentry.init: memory stops increasing.

Actual Result
Memory increases gradually until it OOMs, if
includeLocalVariablesis enabled.If Sentry is disabled entirely, or if the
includeLocalVariablesflag is disabled, then memory looks as expected.I originally suspected this was the issue, since we also use websockets and long-running requests, but after ignoring the requests and confirming via the console.logs that none of the long-running requests got spans created (with the issue still persisting), I tried disabling local variables and that fixed it.
These are (truncated) logs with trace GC enabled. It's not particularly showing much other than memory growth. This shows with local variables enabled, and this is with it disabled.