mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
fix: Don't panic lsp writer thread on dropped receiver
This commit is contained in:
parent
f19a9fe7ba
commit
71a43aff4e
3 changed files with 11 additions and 13 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -998,23 +998,23 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
|||
[[package]]
|
||||
name = "lsp-server"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "248f65b78f6db5d8e1b1604b4098a28b43d21a8eb1deeca22b1c421b276c7095"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"ctrlc",
|
||||
"log",
|
||||
"lsp-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lsp-server"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "248f65b78f6db5d8e1b1604b4098a28b43d21a8eb1deeca22b1c421b276c7095"
|
||||
version = "0.7.7"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"ctrlc",
|
||||
"log",
|
||||
"lsp-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
@ -1652,7 +1652,7 @@ dependencies = [
|
|||
"intern",
|
||||
"itertools",
|
||||
"load-cargo",
|
||||
"lsp-server 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lsp-server 0.7.6",
|
||||
"lsp-types",
|
||||
"memchr",
|
||||
"mimalloc",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "lsp-server"
|
||||
version = "0.7.6"
|
||||
version = "0.7.7"
|
||||
description = "Generic LSP server scaffold."
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/lsp-server"
|
||||
|
|
|
@ -30,7 +30,9 @@ pub(crate) fn stdio_transport() -> (Sender<Message>, Receiver<Message>, IoThread
|
|||
let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit());
|
||||
|
||||
debug!("sending message {:#?}", msg);
|
||||
reader_sender.send(msg).expect("receiver was dropped, failed to send a message");
|
||||
if let Err(e) = reader_sender.send(msg) {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, e));
|
||||
}
|
||||
|
||||
if is_exit {
|
||||
break;
|
||||
|
@ -60,15 +62,11 @@ impl IoThreads {
|
|||
pub fn join(self) -> io::Result<()> {
|
||||
match self.reader.join() {
|
||||
Ok(r) => r?,
|
||||
Err(err) => {
|
||||
println!("reader panicked!");
|
||||
std::panic::panic_any(err)
|
||||
}
|
||||
Err(err) => std::panic::panic_any(err),
|
||||
}
|
||||
match self.writer.join() {
|
||||
Ok(r) => r,
|
||||
Err(err) => {
|
||||
println!("writer panicked!");
|
||||
std::panic::panic_any(err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue