debugger: Handle session restart failures instead of hanging (#32595)
Anthony Eid
created 6 months ago
I also enabled the `Restart` action even for sessions that don't support
restarting because we have a restart fallback now.
Closes #31408
Release Notes:
- Fix bug where a debugger session would never be shutdown on a failed
restart attempt
Change summary
crates/debugger_ui/src/debugger_panel.rs | 22 ++++++++++++++++++++--
crates/debugger_ui/src/debugger_ui.rs | 7 +++----
2 files changed, 23 insertions(+), 6 deletions(-)
Detailed changes
@@ -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);
}
@@ -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();