on master help sign in
LSP: Add request ID to request timeout message (#6010)
0f64f31Michael Davis
helix-lsp/src/client.rs+2−2
@@ -201,7 +201,7 @@ impl Client {
201
201
202 let request = jsonrpc::MethodCall {
202 let request = jsonrpc::MethodCall {
203 jsonrpc: Some(jsonrpc::Version::V2),
203 jsonrpc: Some(jsonrpc::Version::V2),
204− id,
204+ id: id.clone(),
205 method: R::METHOD.to_string(),
205 method: R::METHOD.to_string(),
206 params: Self::value_into_params(params),
206 params: Self::value_into_params(params),
207 };
207 };
@@ -218,7 +218,7 @@ impl Client {
218 // TODO: delay other calls until initialize success
218 // TODO: delay other calls until initialize success
219 timeout(Duration::from_secs(timeout_secs), rx.recv())
219 timeout(Duration::from_secs(timeout_secs), rx.recv())
220 .await
220 .await
221− .map_err(|_| Error::Timeout)? // return Timeout
221+ .map_err(|_| Error::Timeout(id))? // return Timeout
222 .ok_or(Error::StreamClosed)?
222 .ok_or(Error::StreamClosed)?
223 }
223 }
224 }
224 }
helix-lsp/src/jsonrpc.rs+10
@@ -108,6 +108,16 @@ pub enum Id {
108 Str(String),
108 Str(String),
109}
109}
110
110
111+impl std::fmt::Display for Id {
112+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113+ match self {
114+ Id::Null => f.write_str("null"),
115+ Id::Num(num) => write!(f, "{}", num),
116+ Id::Str(string) => f.write_str(string),
117+ }
118+ }
119+}
120+
111/// Protocol Version
121/// Protocol Version
112#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
122#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
113pub enum Version {
123pub enum Version {
helix-lsp/src/lib.rs+2−2
@@ -34,8 +34,8 @@ pub enum Error {
34 Parse(#[from] serde_json::Error),
34 Parse(#[from] serde_json::Error),
35 #[error("IO Error: {0}")]
35 #[error("IO Error: {0}")]
36 IO(#[from] std::io::Error),
36 IO(#[from] std::io::Error),
37− #[error("request timed out")]
37+ #[error("request {0} timed out")]
38− Timeout,
38+ Timeout(jsonrpc::Id),
39 #[error("server closed the stream")]
39 #[error("server closed the stream")]
40 StreamClosed,
40 StreamClosed,
41 #[error("Unhandled")]
41 #[error("Unhandled")]