From d404ddfccfdacc57ec6043079fa1f07f3a50b947 Mon Sep 17 00:00:00 2001 From: Felix F Xu <84662027+felixf4xu@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:02:30 +0800 Subject: [PATCH] fix false notification/rebuild for dx hot-reload (#1684) * fix false notification/rebuild for dx hot-reload * Make sure we have permissions and the changed file exists before reading the metadata --------- Co-authored-by: ealmloff --- packages/cli/src/server/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/cli/src/server/mod.rs b/packages/cli/src/server/mod.rs index 79a5531b6..eb4021184 100644 --- a/packages/cli/src/server/mod.rs +++ b/packages/cli/src/server/mod.rs @@ -55,6 +55,16 @@ async fn setup_file_watcher Result + Send + 'static>( break; } + // Workaround for notify and vscode-like editor: + // when edit & save a file in vscode, there will be two notifications, + // the first one is a file with empty content. + // filter the empty file notification to avoid false rebuild during hot-reload + if let Ok(metadata) = fs::metadata(path) { + if metadata.len() == 0 { + continue; + } + } + match rsx_file_map.update_rsx(path, &config.crate_dir) { Ok(UpdateResult::UpdatedRsx(msgs)) => { messages.extend(msgs);