Skip to content

vfs: read RealFSProvider files from open fd#64104

Open
trivikr wants to merge 2 commits into
nodejs:mainfrom
trivikr:vfs-readfile-fd-post-rename
Open

vfs: read RealFSProvider files from open fd#64104
trivikr wants to merge 2 commits 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
@trivikr trivikr requested a review from mcollina June 25, 2026 05:23
Comment thread lib/internal/vfs/providers/real.js Outdated

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

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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: RealFSProvider readFileSync(fd) fails after backing file is renamed

3 participants