Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
debugger: Handle session restart failures instead of hanging (#32595)
Anthony Eid4e4856f2c12c
diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rsindex c93e70541a0..575d234a603 100644--- a/crates/debugger_ui/src/debugger_panel.rs+++ b/crates/debugger_ui/src/debugger_panel.rs@@ -349,8 +349,26 @@ impl DebugPanel {});(session, task)})?;- Self::register_session(this.clone(), session, true, cx).await?;- task.await+ Self::register_session(this.clone(), session.clone(), true, cx).await?;++ if let Err(error) = task.await {+ session+ .update(cx, |session, cx| {+ session+ .console_output(cx)+ .unbounded_send(format!(+ "Session failed to restart with error: {}",+ error+ ))+ .ok();+ session.shutdown(cx)+ })?+ .await;++ return Err(error);+ };++ Ok(())}).detach_and_log_err(cx);}diff --git a/crates/debugger_ui/src/debugger_ui.rs b/crates/debugger_ui/src/debugger_ui.rsindex f3909b6a63f..595541d3b2b 100644--- a/crates/debugger_ui/src/debugger_ui.rs+++ b/crates/debugger_ui/src/debugger_ui.rs@@ -111,7 +111,6 @@ pub fn init(cx: &mut App) {}let caps = running_state.capabilities(cx);- let supports_restart = caps.supports_restart_request.unwrap_or_default();let supports_step_back = caps.supports_step_back.unwrap_or_default();let supports_detach = running_state.session().read(cx).is_attached();let status = running_state.thread_status(cx);@@ -204,13 +203,13 @@ pub fn init(cx: &mut App) {.ok();})})- .when(supports_restart, |div| {+ .on_action({let active_item = active_item.clone();- div.on_action(move |_: &Restart, _, cx| {+ move |_: &Restart, _, cx| {active_item.update(cx, |item, cx| item.restart_session(cx)).ok();- })+ }}).on_action({let active_item = active_item.clone();