-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Memory leak on Node 19/20 with includeLocalVariables
enabled
#14162
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
Comments
Thanks for reporting this. I tested the recent changes around local variable capture for memory leaks since this has been an issue before. I did see an increase in memory usage with |
I've been unable to reproduce a memory leak with express and If you have a minimal reproduction that I could debug that would help. |
@vitor-ramalho-deel are you able to provide a heap snapshot or reproduction to help us dig in further? It's hard to tell what might be causing this (might be another dependency playing bad with Sentry for example). |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
@tellisnz could you open a new GH issue and fill out the issue template? We'll take a look! |
@AbhiPrasad - created #16041 but to be honest we're not going to chase it, we just simply disabled in prod and can work around it in staging/dev I can't create a good reproduction case with our setup, and company policy precludes providing dependency set, sorry. |
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
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.
The text was updated successfully, but these errors were encountered: