mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
prevent panic when handling an LSP response with no request (#2475)
A language server may push a response which doesn't belong to any request. With this change, we discard the response rather than crashing. In the case of #2474, the language server sends an error message with a null request ID which should not ever exist in the `pending_requests` HashMap. closes #2474
This commit is contained in:
parent
0258cf45f3
commit
50dd11985c
@ -215,13 +215,7 @@ async fn process_request_response(&self, output: jsonrpc::Output) -> Result<()>
|
||||
}
|
||||
};
|
||||
|
||||
let tx = self
|
||||
.pending_requests
|
||||
.lock()
|
||||
.await
|
||||
.remove(&id)
|
||||
.expect("pending_request with id not found!");
|
||||
|
||||
if let Some(tx) = self.pending_requests.lock().await.remove(&id) {
|
||||
match tx.send(result).await {
|
||||
Ok(_) => (),
|
||||
Err(_) => error!(
|
||||
@ -229,6 +223,13 @@ async fn process_request_response(&self, output: jsonrpc::Output) -> Result<()>
|
||||
id
|
||||
),
|
||||
};
|
||||
} else {
|
||||
log::error!(
|
||||
"Discarding Language Server response without a request (id={:?}) {:?}",
|
||||
id,
|
||||
result
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user