diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-01-09 11:36:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 11:36:03 -0500 |
commit | 741afc4b94427588c628925fef464623d373430f (patch) | |
tree | 0900236885f87249cc6fff5066f273ecd9bae6d8 | |
parent | cd43d2b8771e59bb454c20b1504ad4176d195e87 (diff) |
fix(lsp): use a dedicated thread for the parent process checker (#21869)
Ensures the Deno process is brought down even when the runtime gets hung
up on something.
Marvin found that the lsp was running without a parent vscode around so
this is maybe/probably related.
-rw-r--r-- | cli/lsp/parent_process_checker.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/cli/lsp/parent_process_checker.rs b/cli/lsp/parent_process_checker.rs index 016dfd943..e5b2b2f23 100644 --- a/cli/lsp/parent_process_checker.rs +++ b/cli/lsp/parent_process_checker.rs @@ -1,20 +1,17 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::unsync::spawn; -use tokio::time::sleep; -use tokio::time::Duration; +use std::time::Duration; -/// Starts a task that will check for the existence of the +/// Starts a thread that will check for the existence of the /// provided process id. Once that process no longer exists /// it will terminate the current process. pub fn start(parent_process_id: u32) { - spawn(async move { - loop { - sleep(Duration::from_secs(30)).await; + // use a separate thread in case the runtime gets hung up + std::thread::spawn(move || loop { + std::thread::sleep(Duration::from_secs(10)); - if !is_process_active(parent_process_id) { - std::process::exit(1); - } + if !is_process_active(parent_process_id) { + std::process::exit(1); } }); } |