From 21924910128437b95fd5af41d8b624aead7b88a8 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Thu, 7 Nov 2024 22:28:06 +0100 Subject: [PATCH] fix(filewatcher): handle removed directories #8800 When setting up manual recursive watching on folders (as is the case under Linux), the watching thread should not exit if a directory no longer exists. This is likely to occur within build output directories and it should not be the cause for interrupting the daemon. --- crates/turborepo-filewatch/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-filewatch/src/lib.rs b/crates/turborepo-filewatch/src/lib.rs index 29311d7ab79fb7..67bccd66aa52a3 100644 --- a/crates/turborepo-filewatch/src/lib.rs +++ b/crates/turborepo-filewatch/src/lib.rs @@ -271,8 +271,17 @@ async fn watch_events( if event.kind == EventKind::Create(CreateKind::Folder) { for new_path in &event.paths { if let Err(err) = manually_add_recursive_watches(new_path, &mut watcher, Some(&broadcast_sender)) { - warn!("encountered error watching filesystem {}", err); - break 'outer; + match err { + WatchError::WalkDir() => { + // Likely the path no longer exists + continue; + }, + _ => { + warn!("encountered error watching filesystem {}", err); + break 'outer; + } + + } } } }