Skip to content

Commit

Permalink
Auto merge of #18066 - Veykril:lsp-server-no-panic, r=Veykril
Browse files Browse the repository at this point in the history
fix: Don't panic lsp writer thread on dropped receiver

Should reduce the noise a bit (#18055). This removes the panic (and a follow up panic) when the server incorrectly shuts down, turning it into a proper late exit error.
  • Loading branch information
bors committed Sep 6, 2024
2 parents e09dabf + 71a43af commit a0f1832
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/lsp-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 4 additions & 6 deletions lib/lsp-server/src/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit a0f1832

Please sign in to comment.