Hey everyone! This release includes a ton of bug fixes and improvements.
1. Better VFS integrity and syncing (#288)
The VFS now keeps a cache of vnodes for each file system, the vcache. vnodes are locked for reads and writes, meaning two write operations can't access the same inode concurrently. This fixes #256, #287, and #298.
2. Node.js compatibility (#300)
3478fb6 added a way to run the full test suite used by backends (tests/fs) against the native node:fs module. This lead to quite a few bug fixes:
- Fixed
watchFilenot adding the first listener to the listeners set used bystatWatchers - Fixed context not being passed to
statcalls inStatWatcher - Fixed
fs.watchnot respecting abort signal - Fixed incorrect watch event emission
- Fixed invalid file descriptors throwing
EBADFinstead ofERR_OUT_OF_RANGE - Fixed
Dir.closebeing idempotent since it shouldn't be - Fixed recursive
readdirreturningparentPathrelative to the target instead of joined with the requested path - Fixed renaming a directory inside itself throwing
EBUSYinstead ofEINVAL - Fixed
mkdtemp()with a relative prefix createing the directory in/tmpinstead of relative to the cwd - Fixed
ReadStream.close()not passing a "Premature close" error to its callback - Fixed
createReadStreamwith anendoption reading one byte off - Fixed
linkandlinkSyncpath and dest in error being swapped - Fixed error syscalls not matching Node.js (#265)
3. Changes to testing
- Added a setup for running tests against the native
node:fsmodule - Added test flags and configuration (#228)
- Fixed watch tests to reflect actual node event behavior
- Fixed underscore names (e.g.
_setup-example.ts) causing explicitly passed setup files to be skipped byzenfs-test - Fixed tests for mkdtemp not using
/tmp - Error tests now test the syscall as well
- Test commands now use
execFileSyncinstead ofexecSyncfor more input safety - Tests are now more agnostic as to the
fsimplementation - Added JSDoc types to scripts (test, ci, make-index, etc.)
- Added
--silentto test commands to fix issues with npm v12 output - Increased max timeout for tests to avoid failures in slower environments (like CI/CD)
The changes to the watch API fixes some issues with cleanup. That now means tests complete up to 3x faster! (at least on my machine)
4. Misc
- StoreFS now updates the inode atomically (#286)
- Replaced Iterator helpers with spread for compatibility with <ES2025 (#296, thanks @jcubic)
- Fixed streaming reads and writes going directly to the backend. They now go through
Handle. - Fixed ino collisions in
CopyOnWrite - Renamed internal single buffer
Locktype toSBLock - Narrowed the return type of methods from
InodeLiketoInodeforStoreFS,DeviceFS, andIndexFS