on master help sign in
Drain pending requests on language server termination (#4852)
e6dad96Michael Davis
helix-lsp/src/transport.rs+10
@@ -251,6 +251,16 @@ impl Transport {
251 };
251 };
252 }
252 }
253 Err(Error::StreamClosed) => {
253 Err(Error::StreamClosed) => {
254+ // Close any outstanding requests.
255+ for (id, tx) in transport.pending_requests.lock().await.drain() {
256+ match tx.send(Err(Error::StreamClosed)).await {
257+ Ok(_) => (),
258+ Err(_) => {
259+ error!("Could not close request on a closed channel (id={:?})", id)
260+ }
261+ }
262+ }
263+
254 // Hack: inject a terminated notification so we trigger code that needs to happen after exit
264 // Hack: inject a terminated notification so we trigger code that needs to happen after exit
255 use lsp_types::notification::Notification as _;
265 use lsp_types::notification::Notification as _;
256 let notification =
266 let notification =