Title: Memory leak for Express requests with large attached objects · Issue #15528 · getsentry/sentry-javascript · GitHub
Open Graph Title: Memory leak for Express requests with large attached objects · Issue #15528 · getsentry/sentry-javascript
X Title: Memory leak for Express requests with large attached objects · Issue #15528 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/15528
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak for Express requests with large attached objects","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node\n\n### SDK Version\n\n9.2.0\n\n### Framework Version\n\nNode 20.16.3\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nWe'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.\n\nThe issue feels similar to https://github.com/getsentry/sentry-javascript/issues/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. \n\nVersions:\n- Node: 20.16.3\n- Sentry SDK: 9.2.0\n- Express: 4.21.2\n\nSentry usage -- fairly vanilla initialization: \n\n```javascript\nSentry.init({\n dsn: process.env.SENTRY_DSN,\n release: process.env.VERSION,\n environment: process.env.ENV_NAME,\n integrations: [\n nodeProfilingIntegration(),\n ],\n});\n\nconst app = express();\nSentry.setupExpressErrorHandler(app);\n\n/* Other express app setup */\n```\n\nAdding a touch of context in some other error handling middleware, leak is still present if I remove this:\n\n```Javascript\nif (user) {\n Sentry.setUser({\n id: user.id ? user.id : user.toString(),\n username: user.name && `${user.name.first} ${user.name.last}`,\n email: user.email,\n });\n}\n```\n\nSample retention stack:\n\n\nUnfortunately I can't provide a full heapdump or source code from our app to reproduce.\n\n### Steps to Reproduce\n\nSorry, 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:\n\n- Creating an Express app that attaches some large objects to requests\n- Occasionally throwing errors to be caught by Sentry\n- Running some non-trivial request load \n\n### Expected Result\n\nFlat memory usage\n\n### Actual Result\n\nRising memory usage. Sentry 7.12x.x version is 7.120.1:\n\n\n","author":{"url":"https://github.com/john-matroid","@type":"Person","name":"john-matroid"},"datePublished":"2025-02-27T17:43:47Z","url":"https://github.com/getsentry/sentry-javascript/issues/15528"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b84cd616-6e49-871b-eec9-a69209353c61 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D60:2F022B:3A0E27:50CC66:6B043FA2 |
| html-safe-nonce | 138a564f7c7933ed8deacafc988356a9cc1a41fe4c8778abe7faf7390a8a73ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDYwOjJGMDIyQjozQTBFMjc6NTBDQzY2OjZCMDQzRkEyIiwidmlzaXRvcl9pZCI6IjM1NTI1MDM2NDU3Mjk5OTY3MDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3169204a7c2ca7cdf5a547d7084d9b524e1a3421bb864afbae23f45fbaaa3593 |
| hovercard-subject-tag | issue:2885189634 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/15528/issue_layout |
| twitter:image | https://opengraph.githubassets.com/99d10e5f03bc38c1097326729ddf7c706256f756cdfca1a997177522e8433c89/getsentry/sentry-javascript/issues/15528 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/99d10e5f03bc38c1097326729ddf7c706256f756cdfca1a997177522e8433c89/getsentry/sentry-javascript/issues/15528 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | john-matroid |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width