Skip to content

Commit

Permalink
Drain pending requests on language server termination (helix-editor#4852
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
the-mikedavis authored Nov 24, 2022
1 parent 1d21683 commit e6dad96
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions helix-lsp/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ impl Transport {
};
}
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 =
Expand Down

0 comments on commit e6dad96

Please sign in to comment.