Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit a language server if it sends a message with invalid json #9332

Merged
13 changes: 8 additions & 5 deletions helix-lsp/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,14 @@ impl Transport {
}
};
}
Err(Error::StreamClosed) => {
Err(err) => {
if !matches!(err, Error::StreamClosed) {
error!(
"Exiting {} after unexpected error: {err:?}",
&transport.name
);
}

// Close any outstanding requests.
for (id, tx) in transport.pending_requests.lock().await.drain() {
match tx.send(Err(Error::StreamClosed)).await {
Expand Down Expand Up @@ -300,10 +307,6 @@ impl Transport {
}
break;
}
Err(err) => {
error!("{} err: <- {err:?}", transport.name);
break;
}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::{
ui::{self, overlay::overlaid},
};

use log::{debug, error, warn};
use log::{debug, error, info, warn};
#[cfg(not(feature = "integration"))]
use std::io::stdout;
use std::{collections::btree_map::Entry, io::stdin, path::Path, sync::Arc};
Expand Down Expand Up @@ -675,9 +675,13 @@ impl Application {
Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
let notification = match Notification::parse(&method, params) {
Ok(notification) => notification,
Err(helix_lsp::Error::Unhandled) => {
info!("Ignoring Unhandled notification from Language Server");
return;
}
Err(err) => {
bendennis marked this conversation as resolved.
Show resolved Hide resolved
log::error!(
"received malformed notification from Language Server: {}",
error!(
"Ignoring unknown notification from Language Server: {}",
err
);
return;
Expand Down
Loading