mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 19:03:30 +04:00
Drain pending requests on language server termination (#4852)
This prevents a freeze while shutting down when using `efm-langserver`. `efm-langserver` exits immediately after seeing a shutdown request, without responding to the request. We block awaiting the reply to the shutdown request which will never come, so we time out. This change responds to any pending requests with `Err` saying that the stream has been closed.
This commit is contained in:
parent
1d21683321
commit
e6dad960cf
@ -251,6 +251,16 @@ async fn recv(
|
||||
};
|
||||
}
|
||||
Err(Error::StreamClosed) => {
|
||||
// Close any outstanding requests.
|
||||
for (id, tx) in transport.pending_requests.lock().await.drain() {
|
||||
match tx.send(Err(Error::StreamClosed)).await {
|
||||
Ok(_) => (),
|
||||
Err(_) => {
|
||||
error!("Could not close request on a closed channel (id={:?})", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hack: inject a terminated notification so we trigger code that needs to happen after exit
|
||||
use lsp_types::notification::Notification as _;
|
||||
let notification =
|
||||
|
Loading…
Reference in New Issue
Block a user