René's URL Explorer Experiment


Title: stream: fix early drain after Utf8Stream reopen by mcollina · Pull Request #65633 · nodejs/node · GitHub

Open Graph Title: stream: fix early drain after Utf8Stream reopen by mcollina · Pull Request #65633 · nodejs/node

X Title: stream: fix early drain after Utf8Stream reopen by mcollina · Pull Request #65633 · nodejs/node

Description: If a 'ready' listener starts a write after reopen(), the reopen path still emits 'drain' from a nextTick before that write completes, so a listener reading the file on 'drain' can observe it empty. This is the underlying race behind the test-fastutf8stream-reopen flake that 2e8a4b1 deflaked on the test side ("The reopen path also emits a 'drain' of its own from a nextTick before the write has landed") — this fixes the library so 'drain' is never emitted while stream.writing === true. Skip the extra emit when a write is in flight: #release() emits the real 'drain' once the write completes, so no event is lost. The regression test defers the reopened file's fs.write by one setImmediate, which deterministically lands the write after the nextTick on which the premature 'drain' used to fire. It fails without the lib change (asserts writing === false on 'drain'; observed true, file empty) and passes with it. Verified with 800 runs of the test under 16× parallel CPU contention: 0 failures (28/800 before the fix, reproducing the CI signature exactly). Same fix submitted to upstream sonic-boom: pinojs/sonic-boom#255.

Open Graph Description: If a 'ready' listener starts a write after reopen(), the reopen path still emits 'drain' from a nextTick before that write completes, so a listener reading the file on 'drain...

X Description: If a 'ready' listener starts a write after reopen(), the reopen path still emits 'drain' from a nextTick before that write completes, so a listener reading the file ...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5fa6eb4a-1ada-8b49-a890-85e61c016da7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idEACE:1F5F5F:9CDB8A:D03A66:6AED2FA2
html-safe-nonce806a4ba3c05a57c1ad45718a85682dd45d9f23bdca4ae2920b590d950773882a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUNFOjFGNUY1Rjo5Q0RCOEE6RDAzQTY2OjZBRUQyRkEyIiwidmlzaXRvcl9pZCI6IjEwMDU2OTMxNjI4MjAwMjIxNzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca3bfdb95fa6db48bd2a1eec8e482ef2d679daf936cf35edc0bd35b5b4a3b1f4d
hovercard-subject-tagpull_request:4390216345
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/65633/files
twitter:imagehttps://avatars.githubusercontent.com/u/52195?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/52195?s=400&v=4
og:image:altIf a 'ready' listener starts a write after reopen(), the reopen path still emits 'drain' from a nextTick before that write completes, so a listener reading the file on 'drain...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
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
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/65633/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F65633%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%2F65633%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/65633/files
Reloadhttps://github.com/nodejs/node/pull/65633/files
Reloadhttps://github.com/nodejs/node/pull/65633/files
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)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/pulse
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
nodejs-github-bothttps://github.com/nodejs-github-bot
nodejs:mainhttps://github.com/nodejs/node/tree/main
mcollina:fix-utf8stream-reopen-drainhttps://github.com/mcollina/node/tree/fix-utf8stream-reopen-drain
Conversation 4 https://github.com/nodejs/node/pull/65633
Commits 1 https://github.com/nodejs/node/pull/65633/commits
Checks 42 https://github.com/nodejs/node/pull/65633/checks
Files changed https://github.com/nodejs/node/pull/65633/files
Please reload this pagehttps://github.com/nodejs/node/pull/65633/files
stream: fix early drain after Utf8Stream reopen https://github.com/nodejs/node/pull/65633/files#top
Show all changes 1 commit https://github.com/nodejs/node/pull/65633/files
90dfd42 stream: fix early drain after Utf8Stream reopen mcollina Aug 29, 2026 https://github.com/nodejs/node/pull/65633/commits/90dfd42d97cea025ba50185ece9399f9e43aaf35
Clear filters https://github.com/nodejs/node/pull/65633/files
Please reload this pagehttps://github.com/nodejs/node/pull/65633/files
Please reload this pagehttps://github.com/nodejs/node/pull/65633/files
fast-utf8-stream.js https://github.com/nodejs/node/pull/65633/files#diff-6a3f1bdbbc82d2b64ce9c4429a32b647732ba4cc89800613643ecc323a798033
test-fastutf8stream-reopen.js https://github.com/nodejs/node/pull/65633/files#diff-3bfcca958e43d2622439c30cd59963fbff6b9521d43b03e3c3f5a1187afa424c
lib/internal/streams/fast-utf8-stream.jshttps://github.com/nodejs/node/pull/65633/files#diff-6a3f1bdbbc82d2b64ce9c4429a32b647732ba4cc89800613643ecc323a798033
View file https://github.com/mcollina/node/blob/90dfd42d97cea025ba50185ece9399f9e43aaf35/lib/internal/streams/fast-utf8-stream.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/65633/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/65633/files#diff-6a3f1bdbbc82d2b64ce9c4429a32b647732ba4cc89800613643ecc323a798033
https://github.com/nodejs/node/pull/65633/files#diff-6a3f1bdbbc82d2b64ce9c4429a32b647732ba4cc89800613643ecc323a798033
test/parallel/test-fastutf8stream-reopen.jshttps://github.com/nodejs/node/pull/65633/files#diff-3bfcca958e43d2622439c30cd59963fbff6b9521d43b03e3c3f5a1187afa424c
View file https://github.com/mcollina/node/blob/90dfd42d97cea025ba50185ece9399f9e43aaf35/test/parallel/test-fastutf8stream-reopen.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/65633/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/65633/files#diff-3bfcca958e43d2622439c30cd59963fbff6b9521d43b03e3c3f5a1187afa424c
https://github.com/nodejs/node/pull/65633/files#diff-3bfcca958e43d2622439c30cd59963fbff6b9521d43b03e3c3f5a1187afa424c
https://github.com/nodejs/node/pull/65633/files#diff-3bfcca958e43d2622439c30cd59963fbff6b9521d43b03e3c3f5a1187afa424c
Please reload this pagehttps://github.com/nodejs/node/pull/65633/files
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

Viewport: width=device-width


URLs of crawlers that visited me.