Skip to content

vfs: support writeFileSync with virtual fds#64165

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
trivikr:vfs-writefilesync-fd
Jul 2, 2026
Merged

vfs: support writeFileSync with virtual fds#64165
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
trivikr:vfs-writefilesync-fd

Conversation

@trivikr

@trivikr trivikr commented Jun 27, 2026

Copy link
Copy Markdown
Member

Fixes: #64164

This updates VFS fs dispatch so fs.writeFileSync(fd, data) and
fs.appendFileSync(fd, data) work with VFS-owned file descriptors instead of
falling through to the native fs binding and throwing EBADF.

The fd path now writes through the virtual file handle, preserving descriptor
semantics for both memory-backed VFS files and RealFSProvider handles.


Assisted-by: openai:gpt-5.5

Route fs.writeFileSync() and fs.appendFileSync() calls with VFS-owned
file descriptors through the virtual file handle instead of falling
back to the native fs binding. This preserves descriptor semantics for
both memory-backed VFS files and RealFSProvider handles.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. vfs Issues and PRs related to the virtual filesystem subsystem. labels Jun 27, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2026

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 27, 2026

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread lib/internal/vfs/setup.js Outdated
@trivikr trivikr removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 27, 2026
@trivikr trivikr requested a review from jasnell June 27, 2026 17:25
@trivikr trivikr added request-ci Add this label to start a Jenkins CI on a PR. review wanted PRs that need reviews. and removed review wanted PRs that need reviews. labels Jun 27, 2026
@trivikr

trivikr commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

cc existing reviewers @mcollina @gurgunday @jasnell
Can one you provide a approval again, so that CI can be re-run?

The additional changes contain an explicit undefined check requested in review comment #64165 (comment)

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 2, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 2, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 2, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 2, 2026
@nodejs-github-bot nodejs-github-bot merged commit a6d3e93 into nodejs:main Jul 2, 2026
80 of 81 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in a6d3e93

richardlau pushed a commit that referenced this pull request Jul 3, 2026
Route fs.writeFileSync() and fs.appendFileSync() calls with VFS-owned
file descriptors through the virtual file handle instead of falling
back to the native fs binding. This preserves descriptor semantics for
both memory-backed VFS files and RealFSProvider handles.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: #64165
Fixes: #64164
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. vfs Issues and PRs related to the virtual filesystem subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vfs: fs.writeFileSync(fd, ...) does not dispatch virtual file descriptors

5 participants