Skip to content

Commit b450c46

Browse files
authored
merge: #17 from astrodevs-labs/hotfix/slither-server-crash
Slither Crash Hotfix
2 parents ac717c5 + 80451f0 commit b450c46

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

servers/slither-server/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ struct Backend {
2929
impl LanguageServer for Backend {
3030
async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> {
3131
if !is_slither_installed() {
32-
error!("Slither is not installed!");
3332
self.client
3433
.show_message(
3534
MessageType::ERROR,
3635
"Slither is not installed! Please install it and restart the extension",
3736
)
3837
.await;
39-
return Err(tower_lsp::jsonrpc::Error::internal_error());
38+
error!("Slither is not installed!");
39+
self.data.lock().await.has_to_shutdown = true;
4040
}
4141
if !is_solc_installed() {
4242
self.client
@@ -46,7 +46,7 @@ impl LanguageServer for Backend {
4646
)
4747
.await;
4848
error!("Solc is not installed!");
49-
return Err(tower_lsp::jsonrpc::Error::internal_error());
49+
self.data.lock().await.has_to_shutdown = true;
5050
}
5151

5252
info!("Initializing diagnostic receiver ...");
@@ -94,7 +94,13 @@ impl LanguageServer for Backend {
9494
}
9595

9696
async fn initialized(&self, _: InitializedParams) {
97-
info!("Osmium-slither initialized!");
97+
if self.data.lock().await.has_to_shutdown {
98+
error!("Osmium-Solidity-Slither shuting down ...");
99+
info!("This may occur because of missing dependencies or errors. Please check the logs for more information.");
100+
let _ = self.shutdown().await;
101+
} else {
102+
info!("Osmium-Solidity-Slither initialized!");
103+
}
98104
}
99105

100106
async fn did_change_workspace_folders(&self, params: DidChangeWorkspaceFoldersParams) {

servers/slither-server/src/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct SlitherData {
2424
pub sender: Sender<SlitherDiag>,
2525
pub src_paths: Vec<String>,
2626
pub workspace: String,
27+
pub has_to_shutdown: bool,
2728
}
2829

2930
impl SlitherData {
@@ -35,6 +36,7 @@ impl SlitherData {
3536
receiver: Some(receiver),
3637
sender,
3738
workspace: String::new(),
39+
has_to_shutdown: false,
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)