René's URL Explorer Experiment


Title: Memory leak when a Promise is stored on an Express request that's added to a domain · Issue #23862 · nodejs/node · GitHub

Open Graph Title: Memory leak when a Promise is stored on an Express request that's added to a domain · Issue #23862 · nodejs/node

X Title: Memory leak when a Promise is stored on an Express request that's added to a domain · Issue #23862 · nodejs/node

Description: Version: v10.12.0 Platform: Darwin zero-gravitas-lan.jetpants.com 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 Subsystem: domain The following code, which is a reduced tes...

Open Graph Description: Version: v10.12.0 Platform: Darwin zero-gravitas-lan.jetpants.com 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 Subsystem: domain Th...

X Description: Version: v10.12.0 Platform: Darwin zero-gravitas-lan.jetpants.com 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 Subsystem: domain Th...

Opengraph URL: https://github.com/nodejs/node/issues/23862

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak when a Promise is stored on an Express request that's added to a domain","articleBody":"\u003c!--\r\nThank you for reporting a possible bug in Node.js.\r\n\r\nPlease fill in as much of the template below as you can.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify the affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you can.\r\n-->\r\n\r\n* **Version**: v10.12.0\r\n* **Platform**: Darwin zero-gravitas-lan.jetpants.com 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64\r\n* **Subsystem**: domain\r\n\r\n\u003c!-- Please provide more details below this comment. -->\r\n\r\nThe following code, which is a reduced test case using functionality that's relied upon by the popular [Sentry](https://www.npmjs.com/package/@sentry/node) error reporting module, works fine in Node 8.12.0 but consistently leaks memory on each request in Node 10.12.0, 11.0.0, and 9.11.2:\r\n\r\n```js\r\n'use strict';\r\n\r\nconst domain = require('domain');\r\nconst app = require('express')();\r\n\r\napp.use((req, res, next) => {\r\n  let requestDomain = domain.create();\r\n\r\n  requestDomain.add(req);\r\n  requestDomain.on('error', next);\r\n\r\n  requestDomain.run(() => {\r\n    next();\r\n  });\r\n});\r\n\r\napp.get('/', (req, res) => {\r\n  req.cachedPromise = new Promise(resolve => {\r\n    let tenMebibyteString = 'a'.repeat(10 * 1024 * 1024);\r\n    resolve(tenMebibyteString);\r\n  });\r\n\r\n  res.send('hi');\r\n});\r\n\r\napp.listen(5000);\r\n```\r\n\r\nI would expect the `req` object and its `req.cachedPromise` property to be GCed once the response is finished, since no references to it are being held. This is what happens in Node 8. But in Nodes 9, 10, and 11, `req.cachedPromise` never seems to be GCed, causing a steady memory leak.\r\n\r\nI first noticed this issue when I tried to upgrade a production service using Sentry to Node 10. It likely affects anyone who uses Sentry with Express and caches promises on the request object (or on any descendant of the request object).\r\n\r\nThe relevant code in Sentry is here: https://github.com/getsentry/sentry-javascript/blob/839326fbb498c669bd8b9c38bd93d39ca15b6266/packages/node/src/handlers.ts#L220-L229","author":{"url":"https://github.com/rgrove","@type":"Person","name":"rgrove"},"datePublished":"2018-10-25T00:45:08Z","url":"https://github.com/nodejs/node/issues/23862"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3883143d-dc65-9050-9a02-e03b0a29e29e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA188:3709ED:DA33D8:13043E6:6B043DA7
html-safe-nonce5e3bab30fc8b51d4aac23077b899b26e3a356e065af98e2415b2071010e1f2f4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTg4OjM3MDlFRDpEQTMzRDg6MTMwNDNFNjo2QjA0M0RBNyIsInZpc2l0b3JfaWQiOiIyODgyNjkxMDQwNTEzNjM3Nzk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1c05d9c63773724394c73a9204fd2a35d5d4e7e1b37733abcb71de926a10a92c
hovercard-subject-tagissue:373729920
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/23862/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b3150ca6f340258bd22d2c59dfa3cdb2541e1413078f5f50b8245a5eae643efb/nodejs/node/issues/23862
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b3150ca6f340258bd22d2c59dfa3cdb2541e1413078f5f50b8245a5eae643efb/nodejs/node/issues/23862
og:image:altVersion: v10.12.0 Platform: Darwin zero-gravitas-lan.jetpants.com 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 Subsystem: domain Th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamergrove
hostnamegithub.com
expected-hostnamegithub.com
None9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release06dc448a76fe4751ac1db26524aefa3aa3e889a8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/23862#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F23862
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F23862
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/23862
Reloadhttps://github.com/nodejs/node/issues/23862
Reloadhttps://github.com/nodejs/node/issues/23862
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues633 (633)https://github.com/nodejs/node/issues
Pull requests671 (671)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/23862
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/23862
Memory leak when a Promise is stored on an Express request that's added to a domainhttps://github.com/nodejs/node/issues/23862#top
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
domainIssues and PRs related to the domain subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22domain%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
https://github.com/rgrove
rgrovehttps://github.com/rgrove
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issue-373729920
Sentryhttps://www.npmjs.com/package/@sentry/node
https://github.com/getsentry/sentry-javascript/blob/839326fbb498c669bd8b9c38bd93d39ca15b6266/packages/node/src/handlers.ts#L220-L229https://github.com/getsentry/sentry-javascript/blob/839326fbb498c669bd8b9c38bd93d39ca15b6266/packages/node/src/handlers.ts#L220-L229
Nexthttps://github.com/nodejs/node/issues/23862?timeline_page=1
https://github.com/jasnell
jasnellhttps://github.com/jasnell
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-432875765
@mcollinahttps://github.com/mcollina
@addaleaxhttps://github.com/addaleax
addaleaxhttps://github.com/addaleax
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
domainIssues and PRs related to the domain subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22domain%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#event-1925254227
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-432923685
ChALkeRhttps://github.com/ChALkeR
v10.xhttps://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22v10.x%22
v11.xhttps://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22v11.x%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#event-1925918183
https://github.com/ChALkeR
ChALkeRhttps://github.com/ChALkeR
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433018990
@addaleaxhttps://github.com/addaleax
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433021174
@ChALkeRhttps://github.com/ChALkeR
https://github.com/mcollina
mcollinahttps://github.com/mcollina
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433022270
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433033948
https://www.npmjs.com/package/weakhttps://www.npmjs.com/package/weak
https://www.npmjs.com/package/weak-napi…https://www.npmjs.com/package/weak-napi%E2%80%A6
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433034087
https://github.com/ChALkeR
ChALkeRhttps://github.com/ChALkeR
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433035137
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 25, 2018https://github.com/nodejs/node/issues/23862#issuecomment-433036655
@ChALkeRhttps://github.com/ChALkeR
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Nov 20, 2018https://github.com/nodejs/node/issues/23862#issuecomment-440334365
@mcollinahttps://github.com/mcollina
from abovehttps://github.com/nodejs/node/issues/23862#issuecomment-433033948
https://github.com/mcollina
mcollinahttps://github.com/mcollina
on Nov 20, 2018https://github.com/nodejs/node/issues/23862#issuecomment-440335689
@addaleaxhttps://github.com/addaleax
https://github.com/kamilogorek
kamilogorekhttps://github.com/kamilogorek
on Dec 4, 2018https://github.com/nodejs/node/issues/23862#issuecomment-444126491
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Feb 7, 2019https://github.com/nodejs/node/issues/23862#issuecomment-461582927
#25993https://github.com/nodejs/node/pull/25993
danbevhttps://github.com/danbev
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
8679932https://github.com/nodejs/node/commit/86799326077611d694f37753ee3ab6903397f893
on Feb 12, 2019https://github.com/nodejs/node/issues/23862#event-2132633115
danbevhttps://github.com/danbev
on Feb 12, 2019https://github.com/nodejs/node/issues/23862#event-2132633120
domain: avoid circular memory referenceshttps://github.com/nodejs/node/commit/93417ac99521f0164dfacbbc0f7d30806d1ec0e3
93417achttps://github.com/nodejs/node/commit/93417ac99521f0164dfacbbc0f7d30806d1ec0e3
addaleaxhttps://github.com/addaleax
on Feb 13, 2019https://github.com/nodejs/node/issues/23862#event-2137947333
src: add WeakReference utilityhttps://github.com/nodejs/node/commit/731c2731d22951e99d4c86e323c442961a11b943
731c273https://github.com/nodejs/node/commit/731c2731d22951e99d4c86e323c442961a11b943
domain: avoid circular memory referenceshttps://github.com/nodejs/node/commit/60c5099f4b6b67fa7723f1b39ecbc6a75dc320ea
60c5099https://github.com/nodejs/node/commit/60c5099f4b6b67fa7723f1b39ecbc6a75dc320ea
MylesBorinshttps://github.com/MylesBorins
on May 17, 2019https://github.com/nodejs/node/issues/23862#event-2349744742
src: add WeakReference utilityhttps://github.com/MylesBorins/node/commit/19fd3a058c67dedd61b5013a3e96f82a71167bcb
19fd3a0https://github.com/MylesBorins/node/commit/19fd3a058c67dedd61b5013a3e96f82a71167bcb
domain: avoid circular memory referenceshttps://github.com/MylesBorins/node/commit/5f65db2cc0dd9762c9ad93fd327b86b1fda2ab90
5f65db2https://github.com/MylesBorins/node/commit/5f65db2cc0dd9762c9ad93fd327b86b1fda2ab90
src: add WeakReference utilityhttps://github.com/nodejs/node/commit/b9ea23c0edef236250ba5d76db1bc6664a7ac79f
b9ea23chttps://github.com/nodejs/node/commit/b9ea23c0edef236250ba5d76db1bc6664a7ac79f
domain: avoid circular memory referenceshttps://github.com/nodejs/node/commit/25d73aa187b3fb2ed60e6ebf7029b923ba71bc21
25d73aahttps://github.com/nodejs/node/commit/25d73aa187b3fb2ed60e6ebf7029b923ba71bc21
sjarmakhttps://github.com/sjarmak
on Jul 27, 2026https://github.com/nodejs/node/issues/23862#event-28561150357
src: add WeakReference utilityhttps://github.com/sg-evals/nodejs-node/commit/86799326077611d694f37753ee3ab6903397f893
8679932https://github.com/sg-evals/nodejs-node/commit/86799326077611d694f37753ee3ab6903397f893
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/23862
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/23862
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
domainIssues and PRs related to the domain subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22domain%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.