debugger: Fix deadlock in on_app_quit with debugger running (#29372)

This fixes a deadlock that would occur when `DapStore` had its on quit
handler called. The deadlock was caused by `DapStore` spawning on the
main thread while `App::shutdown` blocks the main thread.

We added a debug_panic in GPUI that panics if a foreground task is
spawned while the App context is shutting down. This will help tests
catch hangs in `cx.on_app_quit` calls.

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Anthony Eid
2025-04-25 14:15:10 -04:00
committed by GitHub
co-authored by Conrad Irwin
parent c3570fbcf3
commit c3177e6f5b
10 changed files with 26 additions and 162 deletions
+1 -11
View File
@@ -1,6 +1,6 @@
use crate::{attach_modal::Candidate, tests::start_debug_session_with, *};
use attach_modal::AttachModal;
use dap::{FakeAdapter, client::SessionId};
use dap::FakeAdapter;
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};
use menu::Confirm;
use project::{FakeFs, Project};
@@ -176,14 +176,4 @@ async fn test_show_attach_modal_and_select_process(
assert!(workspace.active_modal::<AttachModal>(cx).is_none());
})
.unwrap();
let shutdown_session = project.update(cx, |project, cx| {
project.dap_store().update(cx, |dap_store, cx| {
let session = dap_store.session_by_id(SessionId(0)).unwrap();
dap_store.shutdown_session(session.read(cx).session_id(), cx)
})
});
shutdown_session.await.unwrap();
}