Skip to content

watch: detect files replaced via unlink and create#63888

Open
marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:watch-monitor-replaced-files
Open

watch: detect files replaced via unlink and create#63888
marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:watch-monitor-replaced-files

Conversation

@marcopiraccini

Copy link
Copy Markdown
Contributor

Fixes: #51621
Refs: #54774

On Linux, --watch stopped restarting after the first time a watched file was replaced via unlink+create or rename (atomic saves, docker compose watch, bind mounts), so it appeared to "only reload the first time".

filterFile watched each file directly, which binds the inotify watch to the file's inode.
On replacement the old inode is unlinked: the watch fires once, then dies; the new file's inode is never watched.

Fix: watch the parent directory non-recursively instead of the file. The directory inode is stable across replacements, and unrelated siblings are still discarded by the filter-mode check in #onChange. macOS/Windows already
watched the directory and were unaffected.

Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 13, 2026
@marcopiraccini marcopiraccini marked this pull request as ready for review June 13, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--watch should monitor replaced files

3 participants