This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
Fix watches on symlinked directories - #4376
Merged
Jake Bailey (jakebailey) merged 14 commits intoJun 22, 2026
Merged
Conversation
Co-authored-by: jakebailey <[email protected]>
Copilot
AI
changed the title
[WIP] Fix watch mode symlink resolution in 7.0.1-rc binary
Fix fanotify watches on symlinked directories
Jun 19, 2026
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Copilot
AI
changed the title
Fix fanotify watches on symlinked directories
Fix watches on symlinked directories
Jun 19, 2026
Member
|
Copilot Windows failure |
Co-authored-by: jakebailey <[email protected]>
Contributor
Author
Member
|
This PR basically just allows directory watches on dirs that are symlinks. It turns out that Node previously allowed such a thing. And TS treats symlinks to dirs as dirs, so it all "worked". |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes watch-mode behavior when the requested watch root is a symlink (or Windows reparse point), by subscribing at the physical target path for OS-level watching while rebasing delivered event paths back under the caller-provided (symlink) root.
Changes:
- Introduces
internal/nativepathhelpers forRealpathandIsSymlinkOrReparsePoint, and routes OS VFS realpath/reparse-point checks through them. - Adds
dirWatch.physicalDirplus path rebasing utilities, and applies them across fswatch backends (inotify/fanotify/kqueue/fsevents/windows). - Adds regression tests for symlinked-root subscriptions and ensures userspace recursive walking does not follow symlinked roots/descendants.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/vfs/osvfs/reparsepoint_other.go | Removes non-Windows stub in favor of centralized nativepath-based implementation. |
| internal/vfs/osvfs/realpath_other.go | Removes fallback realpath implementation from osvfs (moved to nativepath). |
| internal/vfs/osvfs/os.go | Switches osvfs realpath/reparse-point detection to internal/nativepath. |
| internal/nativepath/symlink_windows.go | Provides IsSymlinkOrReparsePoint implementation for Windows (reparse points). |
| internal/nativepath/symlink_windows_test.go | Updates tests/benchmarks for the renamed exported Windows helper. |
| internal/nativepath/symlink_other.go | Adds non-Windows symlink detection via os.Lstat. |
| internal/nativepath/realpath_windows.go | Moves/exports Windows realpath implementation as nativepath.Realpath. |
| internal/nativepath/realpath_other.go | Adds non-win/linux/darwin fallback Realpath using filepath.EvalSymlinks. |
| internal/nativepath/realpath_linux.go | Moves/exports Linux fast realpath implementation (O_PATH + /proc/self/fd). |
| internal/nativepath/realpath_darwin.go | Moves/exports Darwin realpath implementation. |
| internal/nativepath/eintr_unix.go | Moves EINTR-retry helper to nativepath for unix realpath implementations. |
| internal/fswatch/windows.go | Subscribes/validates/stats using physicalDir while emitting paths under logical dir. |
| internal/fswatch/watcher.go | Adds physicalDir to dirWatch and introduces path rebasing for events vs OS subscription paths. |
| internal/fswatch/watcher_test.go | Adds cross-backend tests for symlinked-root subscriptions and descendant-symlink behavior. |
| internal/fswatch/walkdir_windows.go | Prevents treating reparse-point roots as directories in Windows walkDir. |
| internal/fswatch/walkdir_test.go | Adds coverage that walkDir rejects a symlinked root directory. |
| internal/fswatch/kqueue.go | Tracks both logical and physical paths per entry; reads disk state from physical paths while emitting logical paths. |
| internal/fswatch/inotify_linux.go | Rebases watch paths vs delivered paths; watches physical directories while emitting logical paths. |
| internal/fswatch/fsevents_darwin.go | Rebases callback paths to logical roots while using physical roots for subscription/stat. |
| internal/fswatch/fanotify_linux.go | Uses physical paths for marks/handles and rebases to logical paths for event delivery. |
| internal/fswatch/CHANGES.md | Documents the new behavior for symlinked watch roots. |
| .golangci.yml | Extends the linter configuration path matcher to include internal/nativepath. |
Comments suppressed due to low confidence (1)
internal/nativepath/symlink_windows_test.go:183
- mklink detects the Windows "symlink privilege not held" case by matching err.Error() text. That message can be localized or change across Windows/Go versions, making the test flaky. Prefer checking the underlying errno (e.g. errors.Is(err, syscall.ERROR_PRIVILEGE_NOT_HELD) or via *os.LinkError) and then skipping.
Jake Bailey (jakebailey)
requested review from
Andrew Branch (andrewbranch) and
John Favret (johnfav03)
June 19, 2026 22:32
Member
|
lspwatcher handles this itself, so that special handling should be removed. |
Member
|
Indeed, yes. |
Andrew Branch (andrewbranch)
approved these changes
Jun 22, 2026
Jake Bailey (jakebailey)
enabled auto-merge
June 22, 2026 16:44
Andrew Branch (andrewbranch)
approved these changes
Jun 22, 2026
Ryan Hart (rhart92)
pushed a commit
to rhart92/typescript-go
that referenced
this pull request
Aug 2, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
Jake Bailey (jakebailey)
added a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
This was referenced Nov 16, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Watch mode could fail on Bun-style
node_moduleslayouts where requested watch roots are symlinks to package directories. Watchers now resolve a symlinked root to its physical directory for OS subscriptions while preserving the caller-visible symlink path in emitted events.Watch root handling
osvfshelpers instead of usingfilepath.EvalSymlinksdirectly.walkDirfrom following symlinks, including symlinked roots.Watcher backends
Regression coverage
walkDirdoes not follow a symlinked root directory.Example layout now supported: