debugger: Handle session restart failures instead of hanging (#32595)

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
This commit is contained in:
Anthony Eid 2025-06-12 04:29:34 -04:00 committed by GitHub
parent d1ca6db756
commit 4e4856f2c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 6 deletions

View file

@ -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);
}

View file

@ -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();