Skip to content

Commit

Permalink
LS: Cancel background tasks when terminating (#6609)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaput authored Nov 8, 2024
1 parent d390b09 commit 3f74a9c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/cairo-lang-language-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use cairo_lang_project::ProjectConfig;
use cairo_lang_semantic::plugin::PluginSuite;
use lsp_server::Message;
use lsp_types::RegistrationParams;
use salsa::{Database, Durability};
use tracing::{debug, error, info, warn};

use crate::config::Config;
Expand Down Expand Up @@ -293,6 +294,9 @@ impl Backend {

let result = Self::event_loop(&connection, scheduler);

// Trigger cancellation in any background tasks that might still be running.
state.db.salsa_runtime_mut().synthetic_write(Durability::LOW);

if let Err(err) = connection.close() {
error!("failed to close connection to the language server: {err:?}");
}
Expand Down

0 comments on commit 3f74a9c

Please sign in to comment.