Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rebuild when the code is in an invalid intermediate state #2848

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/cli/src/serve/watcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::{fs, path::PathBuf, time::Duration};

use super::hot_reloading_file_map::HotreloadError;
use crate::serve::hot_reloading_file_map::FileMap;
use crate::{cli::serve::Serve, dioxus_crate::DioxusCrate};
use dioxus_hot_reload::HotReloadMsg;
Expand Down Expand Up @@ -246,12 +247,21 @@ impl Watcher {
}

for rust_file in edited_rust_files {
let hotreloaded_templates = self
.file_map
.update_rsx::<HtmlCtx>(&rust_file, &crate_dir)
.ok()?;

templates.extend(hotreloaded_templates);
match self.file_map.update_rsx::<HtmlCtx>(&rust_file, &crate_dir) {
Ok(hotreloaded_templates) => {
templates.extend(hotreloaded_templates);
}
// If the file is not reloadable, we need to rebuild
Err(HotreloadError::Notreloadable) => return None,
// The rust file may have failed to parse, but that is most likely
// because the user is in the middle of adding new code
// We just ignore the error and let Rust analyzer warn about the problem
Err(HotreloadError::Parse) => {}
// Otherwise just log the error
Err(err) => {
tracing::error!("Error hotreloading file {rust_file:?}: {err}")
}
}
}

let msg = HotReloadMsg {
Expand Down
Loading