diff --git a/core/src/infra/daemon/bootstrap.rs b/core/src/infra/daemon/bootstrap.rs index cb0732b61..81f62d7b8 100644 --- a/core/src/infra/daemon/bootstrap.rs +++ b/core/src/infra/daemon/bootstrap.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; use std::sync::Arc; -use tracing::info; +use tracing::{info, warn}; use crate::infra::daemon::rpc::RpcServer; use crate::Core; diff --git a/core/src/service/watcher/mod.rs b/core/src/service/watcher/mod.rs index 37fefa214..73bc426f7 100644 --- a/core/src/service/watcher/mod.rs +++ b/core/src/service/watcher/mod.rs @@ -499,6 +499,7 @@ impl LocationWatcher { let metrics = self.metrics.clone(); let (tx, mut rx) = mpsc::channel(self.config.event_buffer_size); + let tx_clone = tx.clone(); // Create file system watcher let mut watcher = notify::recommended_watcher(move |res| { @@ -514,15 +515,12 @@ impl LocationWatcher { // Convert notify event to our WatcherEvent let watcher_event = WatcherEvent::from_notify_event(event); - // Use spawn_blocking to avoid blocking the notify callback - // This ensures we never drop events - we wait for buffer space - let tx_clone = tx.clone(); - tokio::spawn(async move { - if let Err(e) = tx_clone.send(watcher_event).await { - error!("Failed to send watcher event (receiver dropped): {}", e); - // This should only happen if the receiver is dropped - } - }); + // Send event directly to avoid runtime context issues + // Use try_send since we're in a sync context + if let Err(e) = tx_clone.try_send(watcher_event) { + error!("Failed to send watcher event: {}", e); + // This could happen if the channel is full or receiver is dropped + } } Err(e) => { error!("File system watcher error: {}", e);