Skip to content

fix(watcher): release watch descriptor on subdirectory deletion - #54

Merged
harrydayexe merged 1 commit into
mainfrom
51-unwatch-directories
Jun 8, 2026
Merged

harrydayexe merged 1 commit into
mainfrom
51-unwatch-directories

Conversation

@harrydayexe

@harrydayexe harrydayexe commented Jun 8, 2026 •

Copy link
Copy Markdown
Owner

Deleting a watched subdirectory left its OS-level watch descriptor registered until the process exited. On Linux this leaks inotify fds toward the max_user_watches limit; on macOS it leaks kqueue entries. A removed-then-recreated subdirectory would also silently stop triggering onChange for files written inside it.

On fsnotify.Remove, check whether the path is present in WatchList() (used as the single source of truth because os.Stat fails on an already-deleted path) and call fw.Remove to release the descriptor. Re-creation falls through to the existing Create branch unchanged.

Fixes #51

Changelog (#54)

🐛 Bug Fixes

  • (watcher) release watch descriptor on subdirectory deletion

Deleting a watched subdirectory left its OS-level watch descriptor
registered until the process exited. On Linux this leaks inotify fds
toward the max_user_watches limit; on macOS it leaks kqueue entries.
A removed-then-recreated subdirectory would also silently stop
triggering onChange for files written inside it.

On fsnotify.Remove, check whether the path is present in WatchList()
(used as the single source of truth because os.Stat fails on an
already-deleted path) and call fw.Remove to release the descriptor.
Re-creation falls through to the existing Create branch unchanged.

Fixes #51
@harrydayexe
harrydayexe merged commit ae7d6a3 into main Jun 8, 2026
4 checks passed
@harrydayexe
harrydayexe deleted the 51-unwatch-directories branch June 8, 2026 19:09
harrydayexe added a commit that referenced this pull request Jun 8, 2026
The subdirectory-deletion handler merged in from #54 still referenced
the old local `logger` variable that was removed when config.Logger was
embedded on Watcher. Replace both call sites with w.Logger.Logger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

watcher: handle deletion of watched directories

1 participant