Skip to content

Commit 5b502e5

Browse files
authored
fix(desktop): kill the node sidecar before self-update restart (#61)
app.restart() may not run the RunEvent::Exit handler, so the sidecar server could linger and hold port 34115 — breaking the relaunched (updated) instance's own server. Kill it explicitly before restarting.
1 parent c691515 commit 5b502e5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

app/src-tauri/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ async fn updater_install(
176176
)
177177
.await
178178
.map_err(|e| e.to_string())?;
179+
// Kill the node sidecar before relaunching; restart() may not run the Exit
180+
// handler, and a lingering server would hold port 34115 and break the new
181+
// instance's own sidecar.
182+
#[cfg(not(debug_assertions))]
183+
if let Some(state) = app.try_state::<ServerChild>() {
184+
if let Some(child) = state.0.lock().unwrap().take() {
185+
let _ = child.kill();
186+
}
187+
}
179188
app.restart()
180189
}
181190

0 commit comments

Comments
 (0)