fix: move closure + MutexGuard Send dans la boucle de monitoring
CI / lint (push) Successful in 23s
CI / security (push) Successful in 13s
CI / test (push) Successful in 27s
CI / build (push) Successful in 6s
CI / e2e (push) Failing after 22s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled
CI / lint (push) Successful in 23s
CI / security (push) Successful in 13s
CI / test (push) Successful in 27s
CI / build (push) Successful in 6s
CI / e2e (push) Failing after 22s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled
- setup: move |app| pour ownership de config - monitoring loop: MutexGuard droppé dans un bloc avant wait_for_backend().await
This commit is contained in:
+12
-12
@@ -391,7 +391,7 @@ fn main() {
|
|||||||
save_window_state,
|
save_window_state,
|
||||||
get_window_state,
|
get_window_state,
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(move |app| {
|
||||||
// Restore window position/size
|
// Restore window position/size
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
if let (Some(x), Some(y)) = (config.window_x, config.window_y) {
|
if let (Some(x), Some(y)) = (config.window_x, config.window_y) {
|
||||||
@@ -437,20 +437,20 @@ fn main() {
|
|||||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||||
|
|
||||||
let state = handle2.state::<BackendProcess>();
|
let state = handle2.state::<BackendProcess>();
|
||||||
let mut child_guard = match state.child.lock() {
|
// Drop guard before any await
|
||||||
Ok(g) => g,
|
let died = {
|
||||||
Err(_) => break,
|
let mut child_guard = match state.child.lock() {
|
||||||
|
Ok(g) => g,
|
||||||
|
Err(_) => break,
|
||||||
|
};
|
||||||
|
match &mut *child_guard {
|
||||||
|
Some(child) => child.try_wait().ok().flatten().is_some(),
|
||||||
|
None => true,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let died = match &mut *child_guard {
|
|
||||||
Some(child) => child.try_wait().ok().flatten().is_some(),
|
|
||||||
None => true,
|
|
||||||
};
|
|
||||||
drop(child_guard);
|
|
||||||
|
|
||||||
if died {
|
if died {
|
||||||
warn!("Backend process died unexpectedly!");
|
warn!("Backend process died unexpectedly!");
|
||||||
// Inject a notice into the UI
|
|
||||||
if let Some(window) = handle2.get_webview_window("main") {
|
if let Some(window) = handle2.get_webview_window("main") {
|
||||||
let _ = window.eval(
|
let _ = window.eval(
|
||||||
r#"if (typeof showBackendCrashBanner === 'function') showBackendCrashBanner();"#,
|
r#"if (typeof showBackendCrashBanner === 'function') showBackendCrashBanner();"#,
|
||||||
@@ -458,7 +458,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we were restarting, check if new backend is ready
|
// If restarting, check if new backend is ready
|
||||||
let restarting = state.restarting.lock().ok().map(|r| *r).unwrap_or(false);
|
let restarting = state.restarting.lock().ok().map(|r| *r).unwrap_or(false);
|
||||||
if restarting {
|
if restarting {
|
||||||
if wait_for_backend().await.is_ok() {
|
if wait_for_backend().await.is_ok() {
|
||||||
|
|||||||
Reference in New Issue
Block a user