From fab2f22a89443f2845ed625e3961c3cb23c00d01 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Mon, 28 Oct 2024 17:07:30 +0100 Subject: [PATCH] remote project: Fix project reference leak when waiting for prompt reply (#19838) When the language server gave us a prompt and we'd close the window, we wouldn't release the `project` until the next `flush_effects` call that came in when opening a window. With this change, we no longer hold a strong reference to the project in the future. Fixes the leak and makes sure we clean up the SSH connection when closing a window. Release Notes: - N/A Co-authored-by: Bennet --- crates/project/src/project.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 04ae203b4d..eb5edabc8e 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -3603,6 +3603,13 @@ impl Project { anyhow::Ok(()) })??; + // We drop `this` to avoid holding a reference in this future for too + // long. + // If we keep the reference, we might not drop the `Project` early + // enough when closing a window and it will only get releases on the + // next `flush_effects()` call. + drop(this); + let answer = rx.next().await; Ok(LanguageServerPromptResponse {