From 0c84c917e32af391fed9eaac9e131e447d0a1148 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 23 Sep 2026 12:57:33 -0300 Subject: [PATCH] fix(fs): log file watcher errors (#3621) In plugins/fs/src/watcher.rs, notify errors were discarded (TODO), so a watch that died left no trace. They are now logged with log::error!. Reporting them to the JS callback would change the event payload and is deferred to v3. --- .changes/fix-fs-watch-errors.md | 6 ++++++ plugins/fs/src/watcher.rs | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 .changes/fix-fs-watch-errors.md diff --git a/.changes/fix-fs-watch-errors.md b/.changes/fix-fs-watch-errors.md new file mode 100644 index 000000000..418704489 --- /dev/null +++ b/.changes/fix-fs-watch-errors.md @@ -0,0 +1,6 @@ +--- +fs: patch +fs-js: patch +--- + +File watcher errors (e.g. the watched directory was removed or the inotify limit was reached) are now logged instead of being silently dropped. diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index de9a85d31..68f6a8019 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -69,13 +69,18 @@ pub fn watch( let mut debouncer = new_debouncer( Duration::from_millis(delay), None, - move |events: Result, Vec>| { - if let Ok(events) = events { + move |events: Result, Vec>| match events { + Ok(events) => { for event in events { - // TODO: Should errors be emitted too? let _ = on_event.send(event.event); } } + // TODO(v3): report the errors to the webview + Err(errors) => { + for error in errors { + log::error!("file watcher error: {error}"); + } + } }, )?; for path in &resolved_paths { @@ -84,11 +89,12 @@ pub fn watch( WatcherKind::Debouncer(debouncer) } else { let mut watcher = RecommendedWatcher::new( - move |event| { - if let Ok(event) = event { - // TODO: Should errors be emitted too? + move |event: notify::Result| match event { + Ok(event) => { let _ = on_event.send(event); } + // TODO(v3): report the errors to the webview + Err(error) => log::error!("file watcher error: {error}"), }, Config::default(), )?;