-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Memory leak for Express requests with large attached objects #15528
Comments
Thanks for writing in @john-matroid
What would help is to get an idea of what these large objects are. Are they holding references to buffers or similar? The timeouts in the stack are pointing me to our request session logic, but considering all of this is new logic in sentry-javascript/packages/node/src/integrations/http/SentryHttpInstrumentation.ts Line 470 in 4a7aa21
Can you confirm that |
Appreciate the quick reply here. The objects are ABAC-related permissions objects created by CASL. A lot of the memory use boils down to arrays of objects with a handful of short strings as values. Happy to run 9.2.0 longer to see if the leak is persistent. In terms of the retention pointers, here's what it looked like for 7.120: |
We might end up having to delete the @timfish does that seem reasonable to you? |
Yep that seems reasonable! |
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
9.2.0
Framework Version
Node 20.16.3
Link to Sentry event
No response
Reproduction Example/SDK Setup
We're seeing a Sentry-related memory leak in an Express web server. I suspect the leak has been present for quite some time, but it became more apparent recently when we started attaching large objects (a couple hundred KB to a few MB) to some of our Express requests.
The issue feels similar to #14965, but the retention stack is slightly different, and the issue was not resolved by upgrading to the latest version of the SDK. Feel free to mark as duplicate and reopen there.
Versions:
Sentry usage -- fairly vanilla initialization:
Adding a touch of context in some other error handling middleware, leak is still present if I remove this:
Sample retention stack:

Unfortunately I can't provide a full heapdump or source code from our app to reproduce.
Steps to Reproduce
Sorry, I know how frustrating it is to not get perfect reproduction steps, but I can't share source code. I can take a stab at a minimal reproducing setup if I have some spare time. I'd start by:
Expected Result
Flat memory usage
Actual Result
Rising memory usage. Sentry 7.12x.x version is 7.120.1:
The text was updated successfully, but these errors were encountered: