René's URL Explorer Experiment


Title: Memory leak when using fetch and not consuming the response body · Issue #51162 · nodejs/node · GitHub

Open Graph Title: Memory leak when using fetch and not consuming the response body · Issue #51162 · nodejs/node

X Title: Memory leak when using fetch and not consuming the response body · Issue #51162 · nodejs/node

Description: Version v21.4.0 Platform Linux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux Subsystem fetch API What steps will reproduce the bug? Execute the following sample script with node --expose-gc: const ...

Open Graph Description: Version v21.4.0 Platform Linux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux Subsystem fetch API What steps will reproduce the bug? Execute the following sam...

X Description: Version v21.4.0 Platform Linux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux Subsystem fetch API What steps will reproduce the bug? Execute the following sam...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak when using fetch and not consuming the response body","articleBody":"### Version\n\nv21.4.0\n\n### Platform\n\nLinux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux\n\n### Subsystem\n\nfetch API\n\n### What steps will reproduce the bug?\n\nExecute the following sample script with `node --expose-gc`:\r\n```\r\nconst repro = async () => {\r\n  for (let i = 0; i \u003c 1000; i++) {\r\n    await fetch('https://raw.githubusercontent.com/nodejs/node/main/doc/changelogs/CHANGELOG_V20.md');\r\n    console.log(process.memoryUsage().rss);\r\n  }\r\n}\r\n\r\nrepro()\r\n  .then(() => console.log('Finished'))\r\n  .catch(err => console.log('Error', err));\r\n```\n\n### How often does it reproduce? Is there a required condition?\n\nIt always happen\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe logged memory usage of the process should be consistent and not increase over every execution of the fetch\n\n### What do you see instead?\n\nThe memory usage of the process increases with every request, and it's not ever garbage collected (Even with calling `global.gc()` on every execution.\n\n### Additional information\n\nIf you add a `.then(r => r.text())` or something else that uses the body, the memory leak goes away. I found a similar issue in the `node-fetch` library (https://github.com/node-fetch/node-fetch/issues/83), but I wasn't able to find this leak in nodejs itself. \r\n\r\nFor a workaround, I found that using a Finalization Register, I can create a wrapper function that detects evictions of unneeded response objects, and, if the body was unused, empty the body like this:\r\n```\r\nconst registry = new FinalizationRegistry(response => {\r\n  if (!response || response.bodyUsed) return;\r\n  response.arrayBuffer().catch(console.log);\r\n});\r\n```","author":{"url":"https://github.com/mcat95","@type":"Person","name":"mcat95"},"datePublished":"2023-12-15T08:12:23Z","url":"https://github.com/nodejs/node/issues/51162"}

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:346f14d0-0dbd-9c71-ba11-785916d40f89
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8E5A:2B774B:5B6A58:80BABF:6B041840
html-safe-nonce7e22340cd967d65b027e4eefd5e9cbf89a66346f446e4fdbe8900fbd0211a89e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTVBOjJCNzc0Qjo1QjZBNTg6ODBCQUJGOjZCMDQxODQwIiwidmlzaXRvcl9pZCI6Ijg1NjIwOTc2MzUxNDQ3Njc1NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc9daf115aeeee01997446e70b48d1f7616015ae7f2d81b9637c87b19f574a350
hovercard-subject-tagissue:2043115029
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/51162/issue_layout
twitter:imagehttps://opengraph.githubassets.com/54bb125f4e01811ed7008ddb97dacdf934805481e237cf9703bba0d537b28842/nodejs/node/issues/51162
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/54bb125f4e01811ed7008ddb97dacdf934805481e237cf9703bba0d537b28842/nodejs/node/issues/51162
og:image:altVersion v21.4.0 Platform Linux 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux Subsystem fetch API What steps will reproduce the bug? Execute the following sam...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemcat95
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/51162#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F51162
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%2F51162
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/51162
Reloadhttps://github.com/nodejs/node/issues/51162
Reloadhttps://github.com/nodejs/node/issues/51162
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues633 (633)https://github.com/nodejs/node/issues
Pull requests670 (670)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/51162
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/51162
Memory leak when using fetch and not consuming the response bodyhttps://github.com/nodejs/node/issues/51162#top
fetchIssues and PRs related to the Fetch API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fetch%22
https://github.com/mcat95
mcat95https://github.com/mcat95
on Dec 15, 2023https://github.com/nodejs/node/issues/51162#issue-2043115029
#1https://github.com/nodejs/node/pull/1
node-fetch/node-fetch#83https://github.com/node-fetch/node-fetch/issues/83
marco-ippolitohttps://github.com/marco-ippolito
fetchIssues and PRs related to the Fetch API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fetch%22
on Dec 15, 2023https://github.com/nodejs/node/issues/51162#event-11260348619
https://github.com/marco-ippolito
marco-ippolitohttps://github.com/marco-ippolito
on Dec 15, 2023https://github.com/nodejs/node/issues/51162#issuecomment-1857997472
https://github.com/ronag
ronaghttps://github.com/ronag
on Dec 15, 2023https://github.com/nodejs/node/issues/51162#issuecomment-1858006469
https://undici.nodejs.org/#/?id=garbage-collectionhttps://undici.nodejs.org/#/?id=garbage-collection
ronaghttps://github.com/ronag
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Dec 15, 2023https://github.com/nodejs/node/issues/51162#event-11260484382
https://github.com/cxcorp
cxcorphttps://github.com/cxcorp
on Aug 28, 2024https://github.com/nodejs/node/issues/51162#issuecomment-2314928517
nodejs/undici#3199https://github.com/nodejs/undici/pull/3199
https://github.com/Juraj-Masiar
Juraj-Masiarhttps://github.com/Juraj-Masiar
on Jan 29, 2025https://github.com/nodejs/node/issues/51162#issuecomment-2621941614
https://private-user-images.githubusercontent.com/6358971/408806179-0573c934-3885-444a-b992-336aec4bb3de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTU0MzA3NjUsIm5iZiI6MTc5NTQzMDQ2NSwicGF0aCI6Ii82MzU4OTcxLzQwODgwNjE3OS0wNTczYzkzNC0zODg1LTQ0NGEtYjk5Mi0zMzZhZWM0YmIzZGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjNUMTA0MTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZWEzYTYxOGZhMzFhM2IxZWE5ZjBhNjQ3MWQ1MDY3NTVjYTViMWFmNDA2NmExNzg2OTdkZTE1ZDM5ZmMyMDM5MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.SVPr1HcInhhR0dso5f_gyqzXPPKa53DjV-9-YrTrIHA
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/51162
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/51162
fetchIssues and PRs related to the Fetch API.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fetch%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.