summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-11-22 04:08:48 +0000
committerGitHub <noreply@github.com>2023-11-22 04:08:48 +0000
commit64997cce6a9e83dcc57f5be9056eca16708db096 (patch)
treee6b40c040688ee7700d2f0e52bfefcedda902ce9 /cli/lsp/language_server.rs
parenta8c24d2a8b794eec343a518614cbca0a87b9e2fb (diff)
fix(lsp): force shutdown after a timeout (#21251)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 9b3359db9..f8adb6bb6 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -30,6 +30,7 @@ use std::env;
use std::fmt::Write as _;
use std::path::PathBuf;
use std::sync::Arc;
+use tokio_util::sync::CancellationToken;
use tower_lsp::jsonrpc::Error as LspError;
use tower_lsp::jsonrpc::Result as LspResult;
use tower_lsp::lsp_types::request::*;
@@ -156,7 +157,7 @@ impl LspNpmConfigHash {
}
#[derive(Debug, Clone)]
-pub struct LanguageServer(Arc<tokio::sync::RwLock<Inner>>);
+pub struct LanguageServer(Arc<tokio::sync::RwLock<Inner>>, CancellationToken);
#[derive(Debug)]
pub struct StateNpmSnapshot {
@@ -226,8 +227,11 @@ pub struct Inner {
}
impl LanguageServer {
- pub fn new(client: Client) -> Self {
- Self(Arc::new(tokio::sync::RwLock::new(Inner::new(client))))
+ pub fn new(client: Client, token: CancellationToken) -> Self {
+ Self(
+ Arc::new(tokio::sync::RwLock::new(Inner::new(client))),
+ token,
+ )
}
/// Similar to `deno cache` on the command line, where modules will be cached
@@ -3216,6 +3220,7 @@ impl tower_lsp::LanguageServer for LanguageServer {
}
async fn shutdown(&self) -> LspResult<()> {
+ self.1.cancel();
self.0.write().await.shutdown().await
}