From e2d41c477c8265d067e5be703ab4904feaa87859 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 9 Jul 2026 14:39:43 +0200 Subject: [PATCH] fs: Retry watch registrations skipped during the native watch-limit cooldown (#60662) GlobalWatcher::add returns Ok(None) while the native watch-limit cooldown is active, and FsWatcher::add_existing_path treated that as success: the path was never watched, with no retry and no error. A long-lived watch (like a repository's git directory) that happened to register during a cooldown window silently never received events. Route the skipped registration through the existing pending-path machinery, which already polls until registration succeeds and emits a rescan event for the path so that changes missed in the interim are picked up. --- Release Notes: - N/A or Added/Fixed/Improved ... --- crates/fs/src/fs_watcher.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/fs/src/fs_watcher.rs b/crates/fs/src/fs_watcher.rs index 016d4ca20f3..99664ae7480 100644 --- a/crates/fs/src/fs_watcher.rs +++ b/crates/fs/src/fs_watcher.rs @@ -56,13 +56,22 @@ impl FsWatcher { log::trace!("path to watch is already watched: {path:?}"); return Ok(()); } - if let Some(registration) = register_existing_path( - path, + match register_existing_path( + path.clone(), case_insensitive, self.tx.clone(), self.pending_path_events.clone(), )? { - self.registrations.lock().insert(key, registration); + Some(registration) => { + self.registrations.lock().insert(key, registration); + } + None => { + // Registration was skipped (e.g. the native watch-limit cooldown + // is active). Retry in the background rather than silently leaving + // the path unwatched forever. + log::warn!("watch registration for {path:?} was skipped; retrying in background"); + self.add_pending_path(path); + } } Ok(()) }