npm / memfs
memfs
What changed in memfs 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
5 breaking1 security1 deprecations12 new APIs and options2 performance6 behavior and defaults1 tooling15 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmemfs 443 changes
Breaking changes 5
Symlink resolution is now bounded at 40 and uses an improved algorithm for all open calls.
.unlink() no longer deletes empty directories.
Removed tslib from peerDependencies, changing the package's peer dependency requirements.
Relative paths are no longer allowed during snapshot restoration.
toTreeSync() sorts files and folders in its output.
Security 1
Negative truncate lengths are clamped to zero, preventing an uninitialized-memory leak.
Deprecations 1
Adds the deprecated Dirent.path property with a deprecation notice.
New APIs and options 12
The synchronous FSA worker timeout can now be configured.
A Node-compatible cp module is implemented, allowing developers to use cp functionality with memfs.
Adds glob support to memfs.
Adds support for file birth time.
FsaNodeFs now supports the recursive flag.
Adds a Node-to-FSA watcher bridge.
A FileSystemObserver implementation is available.
Event emission was added to fs-core.
A custom process implementation can now be injected for better testability.
A Result type is implemented, and error handling for exists methods is improved.
Adds the Dirent.parentPath property.
Adds disposable methods to Dir.
Performance 2
The read/write path was improved, which may affect performance when using memfs.
Improves Node buffer allocation and management to prevent O(n^2) overhead.
Behavior and default changes 6
Improvements to
Dirchange its behavior for developers using the API.Improvements to
.opendir()change its behavior for developers using the API.Flags validation errors are improved, making validation failures clearer to developers.
Error normalization is more Node.js-like, affecting the errors developers receive.
The git-fsa directory handle is now persisted.
FSA writable handles now have locking.
Tooling 1
Published sourcemaps now embed sources, which can make source content available when debugging builds.
Fixes and other changes 15
Improves FS(A) error handling.
Returns the correct shape from queryPermission.
Error formatting and normalization are improved.
Relative streams are resolved from the virtual cwd.
BYOB file stream reads now finish at EOF.
Path validation errors are improved, making invalid paths easier to diagnose.
Directory iteration now matches Node's lifecycle.
Improved support for the O_NOFOLLOW flag.
O_APPEND behavior is aligned with Linux.
Fixes handling of drive letters in file URLs.
Enabled cpSync in fsSynchronousApiList.
Enabled statfsSync in fsSynchronousApiList.
Symlinks are now followed when checking for the executable flag.
Fixes EBADF when calling fileHandle.close after streaming via pipeline.
Leading ./ is normalized in relative glob patterns.