From 5f3e7a5f917b678755a84cca6495ca8a922cb072 Mon Sep 17 00:00:00 2001 From: Umesh Yadav <23421535+imumesh18@users.noreply.github.com> Date: Tue, 15 Jul 2025 21:00:57 +0530 Subject: [PATCH] lsp: Wait for shutdown response before sending exit notification (#33417) Follow up: #18634 Closes #33328 Release Notes: - Fixed language server shutdown process to prevent race conditions and improper termination by waiting for shutdown confirmation before closing connections. --- crates/lsp/src/lsp.rs | 7 ++++--- crates/vim/src/test.rs | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 53dc24a21a..ad32d2dd34 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -874,8 +874,6 @@ impl LanguageServer { &executor, (), ); - let exit = Self::notify_internal::(&outbound_tx, &()); - outbound_tx.close(); let server = self.server.clone(); let name = self.name.clone(); @@ -901,7 +899,8 @@ impl LanguageServer { } response_handlers.lock().take(); - exit?; + Self::notify_internal::(&outbound_tx, &()).ok(); + outbound_tx.close(); output_done.recv().await; server.lock().take().map(|mut child| child.kill()); log::debug!("language server shutdown finished"); @@ -1508,6 +1507,8 @@ impl FakeLanguageServer { } }); + fake.set_request_handler::(|_, _| async move { Ok(()) }); + (server, fake) } #[cfg(target_os = "windows")] diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 2db1d4a20c..ce04b621cb 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -1006,8 +1006,6 @@ async fn test_rename(cx: &mut gpui::TestAppContext) { cx.assert_state("const afterˇ = 2; console.log(after)", Mode::Normal) } -// TODO: this test is flaky on our linux CI machines -#[cfg(target_os = "macos")] #[gpui::test] async fn test_remap(cx: &mut gpui::TestAppContext) { let mut cx = VimTestContext::new(cx, true).await; @@ -1048,8 +1046,6 @@ async fn test_remap(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes("g x"); cx.assert_state("1234fooˇ56789", Mode::Normal); - cx.executor().allow_parking(); - // test command cx.update(|_, cx| { cx.bind_keys([KeyBinding::new(