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.
This commit is contained in:
Umesh Yadav 2025-07-15 21:00:57 +05:30 committed by GitHub
parent 0671a4d5ae
commit 5f3e7a5f91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -874,8 +874,6 @@ impl LanguageServer {
&executor,
(),
);
let exit = Self::notify_internal::<notification::Exit>(&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::<notification::Exit>(&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::<request::Shutdown, _, _>(|_, _| async move { Ok(()) });
(server, fake)
}
#[cfg(target_os = "windows")]