From 024285c548c09429ae377e75aebcfbf921ba5283 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 20 Jan 2025 18:58:50 -0800 Subject: [PATCH] fix: don't send hot-reload if app is building (#3607) --- packages/cli/src/build/builder.rs | 5 +++++ packages/cli/src/serve/mod.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/build/builder.rs b/packages/cli/src/build/builder.rs index c021772f5..68e90c954 100644 --- a/packages/cli/src/build/builder.rs +++ b/packages/cli/src/build/builder.rs @@ -315,4 +315,9 @@ impl Builder { _ => false, } } + + /// Check if the queued build is blocking hotreloads + pub(crate) fn can_receive_hotreloads(&self) -> bool { + matches!(&self.stage, BuildStage::Success) + } } diff --git a/packages/cli/src/serve/mod.rs b/packages/cli/src/serve/mod.rs index 4a5b10a3e..5f960bc98 100644 --- a/packages/cli/src/serve/mod.rs +++ b/packages/cli/src/serve/mod.rs @@ -93,10 +93,10 @@ pub(crate) async fn serve_all(mut args: ServeArgs) -> Result<()> { // and then send that update to all connected clients if let Some(hr) = runner.attempt_hot_reload(files).await { // Only send a hotreload message for templates and assets - otherwise we'll just get a full rebuild - if hr.templates.is_empty() - && hr.assets.is_empty() - && hr.unknown_files.is_empty() - { + // + // Also make sure the builder isn't busy since that might cause issues with hotreloads + // https://github.com/DioxusLabs/dioxus/issues/3361 + if hr.is_empty() || !builder.can_receive_hotreloads() { tracing::debug!(dx_src = ?TraceSrc::Dev, "Ignoring file change: {}", file); continue; }