fix(tauri): serialize CLI restart with shutdown

Run the complete CLI stop/start restart while holding the shutdown coordinator authority. Shutdown now waits for an admitted restart, while restart requests arriving after shutdown begins fail without spawning another process.

This prevents final cleanup from racing a restart that could recreate the embedded server immediately before application exit.

Validated with cargo fmt and all 121 Tauri tests on Windows.
This commit is contained in:
Pascal André 2026-08-21 17:24:29 +02:00
parent 4c702cdf36
commit 7a8d06d32b
No known key found for this signature in database

View file

@ -390,13 +390,16 @@ fn cli_restart(
state: tauri::State<AppState>,
) -> Result<CliStatus, String> {
require_local_app_window(&window, &state)?;
let dev_mode = is_dev_mode();
state.manager.stop().map_err(|e| e.to_string())?;
state
.manager
.start(app, dev_mode)
.map_err(|e| e.to_string())?;
Ok(state.manager.status())
shutdown::with_navigation_authority(&app, || {
let dev_mode = is_dev_mode();
state.manager.stop().map_err(|e| e.to_string())?;
state
.manager
.start(app.clone(), dev_mode)
.map_err(|e| e.to_string())?;
Ok(state.manager.status())
})
.unwrap_or_else(|| Err("Application shutdown is in progress".to_string()))
}
#[tauri::command]