Skip to content

vfs: read RealFSProvider files from open fd#64104

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:vfs-readfile-fd-post-rename
Open

vfs: read RealFSProvider files from open fd#64104
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:vfs-readfile-fd-post-rename

Conversation

@trivikr

@trivikr trivikr commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes: #64103

RealFileHandle.readFileSync() and readFile() previously reopened the
original real path. If the backing file was renamed after the VFS fd was opened,
fs.readFileSync(fd, ...) failed with ENOENT.

This changes RealFileHandle to read through the already-open real fd using
positioned reads. That matches native filesystem behavior for renamed open files
and preserves the handle's current offset.

The async readFile() path continues to use async stat() and read()
operations.


Assisted-by: openai:gpt-5.5

Read RealFileHandle contents through the open file descriptor instead
of reopening the original real path. This keeps already-open VFS file
descriptors usable after the backing file is renamed.

Use positioned reads so readFileSync() and readFile() preserve the
handle's current offset.

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 24, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. vfs Issues and PRs related to the virtual filesystem subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vfs: RealFSProvider readFileSync(fd) fails after backing file is renamed

2 participants