Skip to content

Commit

Permalink
LS: Unrecognized LS requests to be cancelled on salsa failures (#6319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Draggu authored Sep 2, 2024
1 parent aadb183 commit e2ff77c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/cairo-lang-language-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,16 @@ impl Backend {
{
spawn_blocking(move || {
catch_unwind(AssertUnwindSafe(f)).map_err(|err| {
if err.is::<Cancelled>() {
// Salsa is broken and sometimes when cancelled throws regular assert instead of
// [`Cancelled`]. Catch this case too.
if err.is::<Cancelled>()
|| err.downcast_ref::<&str>().is_some_and(|msg| {
msg.contains(
"assertion failed: old_memo.revisions.changed_at <= \
revisions.changed_at",
)
})
{
debug!("LSP worker thread was cancelled");
LSPError::request_cancelled()
} else {
Expand Down

0 comments on commit e2ff77c

Please sign in to comment.