[Node] Handle symlinked directories in Node FS mounts - #3551
Merged
Conversation
adamziel
force-pushed
the
codex/node-fs-mount-symlink-directories
branch
2 times, most recently
from
April 28, 2026 18:29
ecf7425 to
f62276b
Compare
adamziel
marked this pull request as ready for review
April 28, 2026 18:36
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates NodeFSMountHandler to treat symlinked directories as directories in the VFS by following symlinks when creating mount-point placeholders, and adds a regression test for unmount cleanup when the mounted directory is the CWD.
Changes:
- Switch placeholder type detection from
lstatSync()tostatSync()to follow symlinks. - Add a regression test ensuring directory-cleanup guard triggers when CWD is inside the mounted directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/php-wasm/node/src/lib/node-fs-mount.ts | Uses statSync() so symlinked dirs get directory placeholders; adds an explanatory inline comment. |
| packages/php-wasm/node/src/test/mount.spec.ts | Adds a regression test covering unmount cleanup behavior when the mount is the current working directory. |
Comments suppressed due to low confidence (1)
packages/php-wasm/node/src/lib/node-fs-mount.ts:39
- This error message is misleading given the new implementation: the check is now based on
statSync()(which resolves symlinks), so the failure can occur for non-symlink paths and the message doesn’t reflect the actual supported mount targets. Consider rewording to something like “supports mounting only files and directories (including symlinks to files/directories)” to match the behavior.
throw new Error(
'Unsupported file type. PHP-wasm supports only symlinks that link to files, directories, or symlinks.'
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
adamziel
force-pushed
the
codex/node-fs-mount-symlink-directories
branch
2 times, most recently
from
April 28, 2026 19:37
1e66db5 to
21e9fd1
Compare
adamziel
force-pushed
the
codex/node-fs-mount-symlink-directories
branch
from
April 28, 2026 19:45
21e9fd1 to
5f34205
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Makes
NodeFSMountHandlerpreserve symlinked directories as directories when mounting host paths into PHP.wasm.Rationale
lstatSync()reports the symlink itself, so a symlink pointing at a directory was treated like a file.statSync()fixes the placeholder decision, butNODEFSalso reads the mount root path. Passing the original symlink path still leaves the mounted root shaped like the symlink.Implementation
Resolves
localPathwithrealpathSync()before creating the VFS placeholder and before callingFS.mount(). The placeholder is then created fromstatSync(mountRoot), andNODEFSreceives the resolved root path.Added a regression test that checks the actual mounted VFS node mode for both normal directories and symlinked directories. Before this PR, the symlinked-directory case produced a non-directory mount node.
Testing instructions
Focused checks run locally:
CI group checks run locally: