Skip to content

Commit 26fc955

Browse files
authored
fix(cli): Re-add TriggeredKill in dev watcher logic (#12178)
1 parent 90dc7b1 commit 26fc955

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri-cli': 'patch:bug'
3+
'@tauri-apps/cli': 'patch:bug'
4+
---
5+
6+
Fixed an issue that caused the `tauri dev` file watcher to exit after detecting file changes.

crates/tauri-cli/src/dev.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ pub fn setup(interface: &AppInterface, options: &mut Options, config: ConfigHand
339339
}
340340

341341
pub fn on_app_exit(code: Option<i32>, reason: ExitReason, exit_on_panic: bool, no_watch: bool) {
342-
if no_watch || exit_on_panic || matches!(reason, ExitReason::NormalExit) {
342+
if no_watch
343+
|| (!matches!(reason, ExitReason::TriggeredKill)
344+
&& (exit_on_panic || matches!(reason, ExitReason::NormalExit)))
345+
{
343346
kill_before_dev_process();
344347
exit(code.unwrap_or(0));
345348
}

crates/tauri-cli/src/interface/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub trait AppSettings {
8787
#[derive(Debug)]
8888
pub enum ExitReason {
8989
/// Killed manually.
90-
// TriggeredKill,
90+
TriggeredKill,
9191
/// App compilation failed.
9292
CompilationFailed,
9393
/// Regular exit.

crates/tauri-cli/src/interface/rust.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ impl Rust {
553553
loop {
554554
if let Ok(events) = rx.recv() {
555555
for event in events {
556-
#[cfg(target_os = "linux")]
557556
if event.kind.is_access() {
558557
continue;
559558
}

crates/tauri-cli/src/interface/rust/desktop.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
7878
dev_cmd.arg("--");
7979
dev_cmd.args(run_args);
8080

81+
let manually_killed_app = Arc::new(AtomicBool::default());
82+
let manually_killed_app_ = manually_killed_app.clone();
83+
8184
let dev_child = match SharedChild::spawn(&mut dev_cmd) {
8285
Ok(c) => Ok(c),
8386
Err(e) if e.kind() == ErrorKind::NotFound => Err(anyhow::anyhow!(
@@ -128,16 +131,15 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
128131
status.code(),
129132
if status.code() == Some(101) && is_cargo_compile_error {
130133
ExitReason::CompilationFailed
134+
} else if manually_killed_app_.load(Ordering::Relaxed) {
135+
ExitReason::TriggeredKill
131136
} else {
132137
ExitReason::NormalExit
133138
},
134139
);
135140
}
136141
});
137142

138-
// TODO: remove this and DevChild (requires refactor for code shared between mobile and desktop)
139-
let manually_killed_app = Arc::new(AtomicBool::default());
140-
141143
Ok(DevChild {
142144
manually_killed_app,
143145
dev_child,

0 commit comments

Comments
 (0)