From 43613fe2acd52099dc433de153c3cc68d2500a96 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 18 Jul 2022 14:55:24 -0700 Subject: [PATCH] Ensure that fs watches are dropped when dropping the event stream --- crates/project/src/fs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/project/src/fs.rs b/crates/project/src/fs.rs index 397d5ea63a..460b788afd 100644 --- a/crates/project/src/fs.rs +++ b/crates/project/src/fs.rs @@ -226,11 +226,13 @@ impl Fs for RealFs { ) -> Pin>>> { let (tx, rx) = smol::channel::unbounded(); let (stream, handle) = EventStream::new(&[path], latency); - std::mem::forget(handle); std::thread::spawn(move || { stream.run(move |events| smol::block_on(tx.send(events)).is_ok()); }); - Box::pin(rx) + Box::pin(rx.chain(futures::stream::once(async move { + drop(handle); + vec![] + }))) } fn is_fake(&self) -> bool {