Version
main
Platform
Subsystem
vfs
What steps will reproduce the bug?
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import vfs from 'node:vfs';
const mountPoint = fs.mkdtempSync(path.join(os.tmpdir(), 'vfs-mount-'));
const mounted = vfs
.create({ emitExperimentalWarning: false })
.mount(mountPoint);
try {
const file = path.join(mountPoint, 'file.txt');
fs.writeFileSync(file, 'abcdef');
const fd = fs.openSync(file, 'r+');
try {
fs.writeFileSync(fd, 'XY');
console.log(fs.readFileSync(file, 'utf8'));
} catch (err) {
console.log('threw:', err.code, err.syscall);
} finally {
fs.closeSync(fd);
}
} finally {
mounted.unmount();
fs.rmSync(mountPoint, { recursive: true, force: true });
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Native fs.writeFileSync(fd, data) writes through the already-open descriptor at its current file position, so virtual fds should be dispatched the same way as fs.readFileSync(fd) and fs.readSync(fd, ...).
What do you see instead?
throws EBADF with syscall write.
Additional information
No response
Version
main
Platform
Subsystem
vfs
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
XYcdefNative
fs.writeFileSync(fd, data)writes through the already-open descriptor at its current file position, so virtual fds should be dispatched the same way asfs.readFileSync(fd)andfs.readSync(fd, ...).What do you see instead?
throws
EBADFwith syscallwrite.Additional information
No response