René's URL Explorer Experiment


Title: src: consolidate C++ ReadFileSync/WriteFileSync utilities by joyeecheung · Pull Request #61662 · nodejs/node · GitHub

Open Graph Title: src: consolidate C++ ReadFileSync/WriteFileSync utilities by joyeecheung · Pull Request #61662 · nodejs/node

X Title: src: consolidate C++ ReadFileSync/WriteFileSync utilities by joyeecheung · Pull Request #61662 · nodejs/node

Description: This patch moves ReadFileSync and WriteFileSync from src/util.cc to src/node_file_utils.cc, consolidates the implementation to reuse code, and adds a few more enhancements: For ReadFileSync: Use fstat-based pre-allocation to minimize buffer resizing and repeated reads for bigger files. Handle various potential overflows in size conversions. Handle fallback for 0-byte special files. For WriteFileSync: Handle potential partial writes for big enough files and support non-seekable files (with -1 as offset). Handle 0-byte writes correctly. In both cases, this now avoids hard aborts and return error code for the caller to handle as much as possible, except std::vector ReadFileSync(FILE* fp) which is part of the embedder API. This patch uses the new ReadFileSync to address a TODO in node_sea.bin.cc. Some numbers from --build-sea (note that most of the time is spent on parsing the executable and building the SEA, but even so there's a measurable difference just from the file I/O because the binary is ~120MB). $ hyperfine "out/Release/node --build-sea sea-config.json" "./node_main --build-sea sea-config.json" --warmup 5 Benchmark 1: out/Release/node --build-sea sea-config.json Time (mean ± σ): 1.696 s ± 0.040 s [User: 1.509 s, System: 0.173 s] Range (min … max): 1.651 s … 1.756 s 10 runs Benchmark 2: ./node_main --build-sea sea-config.json Time (mean ± σ): 1.730 s ± 0.030 s [User: 1.530 s, System: 0.183 s] Range (min … max): 1.681 s … 1.787 s 10 runs Summary out/Release/node --build-sea sea-config.json ran 1.02 ± 0.03 times faster than ./node_main --build-sea sea-config.json

Open Graph Description: This patch moves ReadFileSync and WriteFileSync from src/util.cc to src/node_file_utils.cc, consolidates the implementation to reuse code, and adds a few more enhancements: For ReadFileSync: Use f...

X Description: This patch moves ReadFileSync and WriteFileSync from src/util.cc to src/node_file_utils.cc, consolidates the implementation to reuse code, and adds a few more enhancements: For ReadFileSync: Use f...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c93361f2-73e4-9d51-6000-8f755d61c08e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDF6E:30F31D:A6E435:DE9ABB:6A4C530E
html-safe-nonce6895ea83335081a84f42ca09666665a26e7ddd9e5de0f12a9a2fb52a5c982810
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjZFOjMwRjMxRDpBNkU0MzU6REU5QUJCOjZBNEM1MzBFIiwidmlzaXRvcl9pZCI6IjU2NTQwMzY3MDAyMDkwMzY5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac24041db93aa33eed6aeb2394c069a0af35b33b1d14a63cab9065eaa8512e375f
hovercard-subject-tagpull_request:3242787079
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/61662/files
twitter:imagehttps://avatars.githubusercontent.com/u/4299420?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4299420?s=400&v=4
og:image:altThis patch moves ReadFileSync and WriteFileSync from src/util.cc to src/node_file_utils.cc, consolidates the implementation to reuse code, and adds a few more enhancements: For ReadFileSync: Use f...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c
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
release14099438da5379150f15a2892474c7c7e6c0e55e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/61662/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F61662%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F61662%2Ffiles
Sign up https://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/61662/files
Reloadhttps://github.com/nodejs/node/pull/61662/files
Reloadhttps://github.com/nodejs/node/pull/61662/files
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.4k https://github.com/nodejs/node/issues
Pull requests 964 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://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
joyeecheunghttps://github.com/joyeecheung
nodejs:mainhttps://github.com/nodejs/node/tree/main
joyeecheung:file-utilshttps://github.com/joyeecheung/node/tree/file-utils
Conversation 12 https://github.com/nodejs/node/pull/61662
Commits 2 https://github.com/nodejs/node/pull/61662/commits
Checks 46 https://github.com/nodejs/node/pull/61662/checks
Files changed https://github.com/nodejs/node/pull/61662/files
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
src: consolidate C++ ReadFileSync/WriteFileSync utilities https://github.com/nodejs/node/pull/61662/files#top
Show all changes 2 commits https://github.com/nodejs/node/pull/61662/files
0ae8c1a src: consolidate C++ ReadFileSync/WriteFileSync utilities joyeecheung Feb 3, 2026 https://github.com/nodejs/node/pull/61662/commits/0ae8c1afd6ac9643cfeeb1cb60502fdcdb836ab3
48ed3ef fixup! src: consolidate C++ ReadFileSync/WriteFileSync utilities joyeecheung Feb 5, 2026 https://github.com/nodejs/node/pull/61662/commits/48ed3efd5bc97273d9aee1823df9e1c3411aea04
Clear filters https://github.com/nodejs/node/pull/61662/files
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
node.gyp https://github.com/nodejs/node/pull/61662/files#diff-9f1d0716c75f4df39d9e88499ac205b50301c0c672b816ce54d5339be4c2238c
node_file_utils.cc https://github.com/nodejs/node/pull/61662/files#diff-7e91179b8aa201f3ab9c9847d04a819389b33f02eb826701832045bd16887503
node_file_utils.h https://github.com/nodejs/node/pull/61662/files#diff-c6380d6fe2ac1940c75cec7e69c6744b0775709067a42d6ad52fee1c5d25edf1
node_internals.h https://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
node_sea_bin.cc https://github.com/nodejs/node/pull/61662/files#diff-6606aa503c889028aa795ae91f042957e4abdc74f55e65f8ae3226e11818835f
util.cc https://github.com/nodejs/node/pull/61662/files#diff-26743ee03d8e643c058f9cfa835705beadaa579c3b6220cb728940b11ab6e56f
util.h https://github.com/nodejs/node/pull/61662/files#diff-40ab92941994ec9418dbb76ae46d5aef0e4cb8b034f2be2b31562bb9aca8070f
node.gyphttps://github.com/nodejs/node/pull/61662/files#diff-9f1d0716c75f4df39d9e88499ac205b50301c0c672b816ce54d5339be4c2238c
View file https://github.com/joyeecheung/node/blob/48ed3efd5bc97273d9aee1823df9e1c3411aea04/node.gyp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/61662/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/61662/files#diff-9f1d0716c75f4df39d9e88499ac205b50301c0c672b816ce54d5339be4c2238c
https://github.com/nodejs/node/pull/61662/files#diff-9f1d0716c75f4df39d9e88499ac205b50301c0c672b816ce54d5339be4c2238c
src/node_file_utils.cchttps://github.com/nodejs/node/pull/61662/files#diff-7e91179b8aa201f3ab9c9847d04a819389b33f02eb826701832045bd16887503
View file https://github.com/joyeecheung/node/blob/48ed3efd5bc97273d9aee1823df9e1c3411aea04/src/node_file_utils.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/61662/{{ revealButtonHref }}
src/node_file_utils.hhttps://github.com/nodejs/node/pull/61662/files#diff-c6380d6fe2ac1940c75cec7e69c6744b0775709067a42d6ad52fee1c5d25edf1
View file https://github.com/joyeecheung/node/blob/48ed3efd5bc97273d9aee1823df9e1c3411aea04/src/node_file_utils.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/61662/{{ revealButtonHref }}
src/node_internals.hhttps://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
View file https://github.com/joyeecheung/node/blob/48ed3efd5bc97273d9aee1823df9e1c3411aea04/src/node_internals.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/61662/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
https://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
https://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
https://github.com/nodejs/node/pull/61662/files#diff-6648b37276e20be36473a32445be879f73cedc8d557c06a8a8dfc9adb013a42d
src/node_sea_bin.cchttps://github.com/nodejs/node/pull/61662/files#diff-6606aa503c889028aa795ae91f042957e4abdc74f55e65f8ae3226e11818835f
View file https://github.com/joyeecheung/node/blob/48ed3efd5bc97273d9aee1823df9e1c3411aea04/src/node_sea_bin.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/61662/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/61662/files#diff-6606aa503c889028aa795ae91f042957e4abdc74f55e65f8ae3226e11818835f
https://github.com/nodejs/node/pull/61662/files#diff-6606aa503c889028aa795ae91f042957e4abdc74f55e65f8ae3226e11818835f
https://github.com/nodejs/node/pull/61662/files#diff-6606aa503c889028aa795ae91f042957e4abdc74f55e65f8ae3226e11818835f
Please reload this pagehttps://github.com/nodejs/node/pull/61662/files
Please reload this pagehttps://github.com/nodejs/node/pull/61662/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.