mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
LSP: Add request ID to request timeout message (#6010)
This improves error logging for requests - without the ID it's hard to know which request is the one that timed out.
This commit is contained in:
parent
d8526a752c
commit
0f64f31d8b
@ -201,7 +201,7 @@ fn call<R: lsp::request::Request>(
|
||||
|
||||
let request = jsonrpc::MethodCall {
|
||||
jsonrpc: Some(jsonrpc::Version::V2),
|
||||
id,
|
||||
id: id.clone(),
|
||||
method: R::METHOD.to_string(),
|
||||
params: Self::value_into_params(params),
|
||||
};
|
||||
@ -218,7 +218,7 @@ fn call<R: lsp::request::Request>(
|
||||
// TODO: delay other calls until initialize success
|
||||
timeout(Duration::from_secs(timeout_secs), rx.recv())
|
||||
.await
|
||||
.map_err(|_| Error::Timeout)? // return Timeout
|
||||
.map_err(|_| Error::Timeout(id))? // return Timeout
|
||||
.ok_or(Error::StreamClosed)?
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,16 @@ pub enum Id {
|
||||
Str(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Id {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Id::Null => f.write_str("null"),
|
||||
Id::Num(num) => write!(f, "{}", num),
|
||||
Id::Str(string) => f.write_str(string),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Protocol Version
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum Version {
|
||||
|
@ -34,8 +34,8 @@ pub enum Error {
|
||||
Parse(#[from] serde_json::Error),
|
||||
#[error("IO Error: {0}")]
|
||||
IO(#[from] std::io::Error),
|
||||
#[error("request timed out")]
|
||||
Timeout,
|
||||
#[error("request {0} timed out")]
|
||||
Timeout(jsonrpc::Id),
|
||||
#[error("server closed the stream")]
|
||||
StreamClosed,
|
||||
#[error("Unhandled")]
|
||||
|
Loading…
Reference in New Issue
Block a user