René's URL Explorer Experiment


Title: doc: note that FreeEnvironment() must not run inside uv_run() by magurotuna · Pull Request #67660 · nodejs/node · GitHub

Open Graph Title: doc: note that FreeEnvironment() must not run inside uv_run() by magurotuna · Pull Request #67660 · nodejs/node

X Title: doc: note that FreeEnvironment() must not run inside uv_run() by magurotuna · Pull Request #67660 · nodejs/node

Description: FreeEnvironment() runs the event loop because CleanupHandles() calls uv_run(). libuv states that uv_run() must not be called from a callback. The embedding docs do not mention this rule for FreeEnvironment(). This PR adds a warning to doc/api/embedding.md and src/node.h. The new paragraph in doc/api/embedding.md tells embedders to call FreeEnvironment() after the loop stops. Calling FreeEnvironment() from a loop callback can hang. This repro shows the hang on Linux, macOS, and Windows with Node.js 24, 26, and the 2026-11-19 nightly (CI run). In the repro, two fs.stat() calls finish together: one in the main Environment and one in a second Environment. The libuv loop takes both finished requests at once and then runs their callbacks one by one. The first callback calls FreeEnvironment() on the second Environment. FreeEnvironment() waits for the second fs.stat() request, but the loop already took that request. The loop can run the second callback only after FreeEnvironment() returns, so the wait never ends. Question: freeing an Environment from an addon The updated docs tell embedders to call FreeEnvironment() after the loop stops. However, addon code usually runs inside a loop callback, for example when JavaScript calls it. How should an addon free an Environment? My workaround in magurotuna/vitest-pool-fastforks#14 makes uv_run() return early with uv_stop() and frees the Environment in a platform task: // Called from JavaScript, so inside uv_run(). void FreeLater(node::Environment* env) { pending.push_back(env); uv_idle_start(&idle, [](uv_idle_t*) {}); // Keep the poll phase from blocking. uv_check_start(&check, OnCheck); } // Runs in the check phase of the same loop iteration. void OnCheck(uv_check_t* handle) { uv_idle_stop(&idle); uv_check_stop(handle); uv_stop(handle->loop); // uv_run() returns after this iteration. runner->PostTask(std::make_unique()); // Calls FreeEnvironment(). } SpinEventLoop() runs platform tasks (DrainTasks()) after uv_run() returns, so FreeTask runs outside uv_run(). The full code is freeLater() in the repro. Its deferred mode does not hang on any CI job. Can embedders rely on this order? Refs: #65691 AI disclosure: I used Claude Code to research and to help write the added doc and PR body. I reviewed all of them.

Open Graph Description: FreeEnvironment() runs the event loop because CleanupHandles() calls uv_run(). libuv states that uv_run() must not be called from a callback. The embedding docs do not mention this rule for FreeEnv...

X Description: FreeEnvironment() runs the event loop because CleanupHandles() calls uv_run(). libuv states that uv_run() must not be called from a callback. The embedding docs do not mention this rule for FreeEnv...

Opengraph URL: https://github.com/nodejs/node/pull/67660

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e9f5bd0c-3812-26e4-41ea-2f7da812115c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id84C6:20D128:44BA2F:5B42D5:6B0381D8
html-safe-nonce0e0d1d884055361ad0a35bb558631b22f35b9252de0d8c6282650ace5d5b14d6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEM2OjIwRDEyODo0NEJBMkY6NUI0MkQ1OjZCMDM4MUQ4IiwidmlzaXRvcl9pZCI6IjU0NTM0MzI2Nzc0Njg0MzkwMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0ecc6a1356cf8d67f05ae310f1e035d6d5da3d787eb4373a241418a4a3dc2c6d
hovercard-subject-tagpull_request:5415249762
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/pull/67660/files
twitter:imagehttps://avatars.githubusercontent.com/u/23649474?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/23649474?s=400&v=4
og:image:altFreeEnvironment() runs the event loop because CleanupHandles() calls uv_run(). libuv states that uv_run() must not be called from a callback. The embedding docs do not mention this rule for FreeEnv...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
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

Links:

Skip to contenthttps://github.com/nodejs/node/pull/67660/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F67660%2Ffiles
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%2Fpull%2F67660%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/pull/67660/files
Reloadhttps://github.com/nodejs/node/pull/67660/files
Reloadhttps://github.com/nodejs/node/pull/67660/files
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues639 (639)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
Sign up for GitHub https://github.com/signup?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
magurotunahttps://github.com/magurotuna
nodejs:mainhttps://github.com/nodejs/node/tree/main
magurotuna:doc-freeenvironment-uv-runhttps://github.com/magurotuna/node/tree/doc-freeenvironment-uv-run
Conversation 3 https://github.com/nodejs/node/pull/67660
Commits 1 https://github.com/nodejs/node/pull/67660/commits
Checks 1 https://github.com/nodejs/node/pull/67660/checks
Files changed 2 https://github.com/nodejs/node/pull/67660/files
doc: note that FreeEnvironment() must not run inside uv_run() https://github.com/nodejs/node/pull/67660/files#top
Show all changes 1 commit https://github.com/nodejs/node/pull/67660/files
ffbadc2 doc: note that FreeEnvironment() must not run inside uv_run() magurotuna Nov 18, 2026 https://github.com/nodejs/node/pull/67660/commits/ffbadc23ce07b7993b08e726130247f90f2bdf24
Clear filters https://github.com/nodejs/node/pull/67660/files
Please reload this pagehttps://github.com/nodejs/node/pull/67660/files
Please reload this pagehttps://github.com/nodejs/node/pull/67660/files
embedding.md https://github.com/nodejs/node/pull/67660/files#diff-7d212de8d0bcc7fd11b8685f8d86e63934a82174cfd3f01be68157d1554405d1
node.h https://github.com/nodejs/node/pull/67660/files#diff-7c19dd5fd5584cd4a8111f4c82a9f49f4aa1bdb9470ad11daa90f3d394a23b4e
doc/api/embedding.mdhttps://github.com/nodejs/node/pull/67660/files#diff-7d212de8d0bcc7fd11b8685f8d86e63934a82174cfd3f01be68157d1554405d1
View file https://github.com/magurotuna/node/blob/ffbadc23ce07b7993b08e726130247f90f2bdf24/doc/api/embedding.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/67660/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/67660/files#diff-7d212de8d0bcc7fd11b8685f8d86e63934a82174cfd3f01be68157d1554405d1
https://github.com/nodejs/node/pull/67660/files#diff-7d212de8d0bcc7fd11b8685f8d86e63934a82174cfd3f01be68157d1554405d1
src/node.hhttps://github.com/nodejs/node/pull/67660/files#diff-7c19dd5fd5584cd4a8111f4c82a9f49f4aa1bdb9470ad11daa90f3d394a23b4e
View file https://github.com/magurotuna/node/blob/ffbadc23ce07b7993b08e726130247f90f2bdf24/src/node.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/67660/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/67660/files#diff-7c19dd5fd5584cd4a8111f4c82a9f49f4aa1bdb9470ad11daa90f3d394a23b4e
https://github.com/nodejs/node/pull/67660/files#diff-7c19dd5fd5584cd4a8111f4c82a9f49f4aa1bdb9470ad11daa90f3d394a23b4e
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-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.