fix: Recognize salsa cycles in thread_result_to_response

This commit is contained in:
Lukas Wirth 2025-05-28 14:24:02 +02:00 committed by Lukas Wirth
parent 751ca9ec0d
commit 07e4d5826f

View file

@ -6,7 +6,7 @@ use std::{
use ide_db::base_db::{ use ide_db::base_db::{
DbPanicContext, DbPanicContext,
salsa::{self, Cancelled}, salsa::{self, Cancelled, UnexpectedCycle},
}; };
use lsp_server::{ExtractError, Response, ResponseError}; use lsp_server::{ExtractError, Response, ResponseError};
use serde::{Serialize, de::DeserializeOwned}; use serde::{Serialize, de::DeserializeOwned};
@ -349,11 +349,14 @@ where
let mut message = "request handler panicked".to_owned(); let mut message = "request handler panicked".to_owned();
if let Some(panic_message) = panic_message { if let Some(panic_message) = panic_message {
message.push_str(": "); message.push_str(": ");
message.push_str(panic_message) message.push_str(panic_message);
} else if let Some(cycle) = panic.downcast_ref::<UnexpectedCycle>() {
tracing::error!("{cycle}");
message.push_str(": unexpected cycle");
} else if let Ok(cancelled) = panic.downcast::<Cancelled>() { } else if let Ok(cancelled) = panic.downcast::<Cancelled>() {
tracing::error!("Cancellation propagated out of salsa! This is a bug"); tracing::error!("Cancellation propagated out of salsa! This is a bug");
return Err(HandlerCancelledError::Inner(*cancelled)); return Err(HandlerCancelledError::Inner(*cancelled));
} };
Ok(lsp_server::Response::new_err( Ok(lsp_server::Response::new_err(
id, id,