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
@mstaicu

mstaicu commented Aug 7, 2026

Copy link
Copy Markdown

When can we expect this to be merged?

@trivikr trivikr added watch-mode Issues and PRs related to watch mode request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. labels Aug 21, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 21, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. needs-ci PRs that need a full CI run. watch-mode Issues and PRs related to watch mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--watch should monitor replaced files

5 participants