Skip to content

fs: add node:fs/synchronous - #67771

Open
LiviaMedeiros wants to merge 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-synchronous
Open

LiviaMedeiros wants to merge 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-synchronous

Conversation

@LiviaMedeiros

@LiviaMedeiros LiviaMedeiros commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

This PR was born out of curiosity if this is feasible without breaking everything and affecting performance. It adds node:fs/synchronous export, similar to node:fs/promises but for Synchronous API methods, stripping Sync suffixes from them.

lib/fs.js is the second biggest (only topped by lib/internal/quic/quic.js) file in lib in terms of line count, mainly because it implements both Callback API and Synchronous API. This basically splits it in two halves, making each implementation scoped in own file, and aggregates sync methods on dedicated object.

From userland perspective, it's a sugar for scripts that deliberately prefer only sync methods.

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1909/

Signed-off-by: LiviaMedeiros <livia@cirno.name>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Nov 25, 2026
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.21936% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.56%. Comparing base (5baf5a6) to head (3151c2a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/synchronous.js 96.95% 53 Missing ⚠️
lib/internal/fs/utils.js 98.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67771      +/-   ##
==========================================
+ Coverage   90.53%   90.56%   +0.02%     
==========================================
  Files         803      805       +2     
  Lines      285202   285525     +323     
  Branches    55070    55085      +15     
==========================================
+ Hits       258195   258573     +378     
+ Misses      17147    17101      -46     
+ Partials     9860     9851       -9     
Files with missing lines Coverage Δ
lib/fs.js 97.09% <100.00%> (-0.03%) ⬇️
lib/fs/synchronous.js 100.00% <100.00%> (ø)
lib/internal/fs/utils.js 96.27% <98.87%> (+0.18%) ⬆️
lib/internal/fs/synchronous.js 96.95% <96.95%> (ø)

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aduh95 aduh95 added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 25, 2026
@aduh95

aduh95 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adding semver-major PRs that contain breaking changes and should be released in the next major version. as adding an unscoped built-in module is a potential breaking change. Could we put the exposition of lib/internal/fs/synchronous.js to userland in a separate commit so this can be backported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants