diff options
author | Blaž Hrastnik | 2021-01-06 08:48:14 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-01-06 08:48:14 +0000 |
commit | 941c34a7fc86e613b41887174c699be52ab202a8 (patch) | |
tree | 36bdaf9f2ac4ff19e01ba4588639785e5093999b /helix-lsp | |
parent | b2800489dedb44cf030cd425d737ea14491518aa (diff) |
lsp: Move timeouts into client.request
Diffstat (limited to 'helix-lsp')
-rw-r--r-- | helix-lsp/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-lsp/src/client.rs | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index 18aa90d0..caf9287a 100644 --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -13,6 +13,7 @@ once_cell = "1.4" lsp-types = { version = "0.86", features = ["proposed"] } smol = "1.2" +smol-timeout = "0.6" url = "2" pathdiff = "0.2" shellexpand = "2.0" diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 207e2970..e3f72a56 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -114,7 +114,14 @@ impl Client { .await .map_err(|e| Error::Other(e.into()))?; - let response = rx.recv().await.map_err(|e| Error::Other(e.into()))??; + use smol_timeout::TimeoutExt; + use std::time::Duration; + + let response = match rx.recv().timeout(Duration::from_secs(2)).await { + Some(response) => response, + None => return Err(Error::Timeout), + } + .map_err(|e| Error::Other(e.into()))??; let response = serde_json::from_value(response)?; |