vfs: return FileHandle from fs.promises.open · nodejs/node@de552bd · GitHub
Skip to content

Commit de552bd

Browse files
trivikraduh95
authored andcommitted
vfs: return FileHandle from fs.promises.open
Wrap mounted virtual file descriptors in the public FileHandle interface while delegating operations to the underlying provider handle. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol PR-URL: #65730 Fixes: #65729 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 69911bf commit de552bd

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎lib/internal/vfs/fd.js‎

Lines changed: 39 additions & 0 deletions

‎lib/internal/vfs/setup.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const {
3030
getLayerIdFromPath,
3131
getNormalizedVfsRoot,
3232
} = require('internal/vfs/router');
33-
const { getVirtualFd, closeVirtualFd } = require('internal/vfs/fd');
33+
const { getVirtualFd, closeVirtualFd, createVfsFileHandle } = require('internal/vfs/fd');
3434
const { assertEncoding, setVfsHandlers } = require('internal/fs/utils');
3535
const permission = require('internal/process/permission');
3636
const { getOptionValue } = require('internal/options');
@@ -786,8 +786,7 @@ function createVfsHandlers() {
786786
const r = findVFSForPath(pathStr);
787787
if (r !== null) {
788788
const fd = r.vfs.openSync(r.path, flags, mode);
789-
const vfd = getVirtualFd(fd);
790-
return PromiseResolve(vfd.entry);
789+
return PromiseResolve(createVfsFileHandle(getVirtualFd(fd)));
791790
}
792791
}
793792
return undefined;

‎test/parallel/test-vfs-fs-promises.js‎

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)