From b90ac2dc075b7151c26c0d821c3fe7c3b39ca196 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 5 Dec 2025 16:20:50 -0500 Subject: [PATCH] Fix Drop impl for WasmExtension --- crates/extension_host/src/wasm_host.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs index b9cb265ec59de6ca8009897ddda0a5164f099995..cfd75f7a10fce04076350bf4d3f3ad7e42d21899 100644 --- a/crates/extension_host/src/wasm_host.rs +++ b/crates/extension_host/src/wasm_host.rs @@ -68,7 +68,7 @@ pub struct WasmHost { #[derive(Clone, Debug)] pub struct WasmExtension { - tx: UnboundedSender, + tx: Arc>, pub manifest: Arc, pub work_dir: Arc, #[allow(unused)] @@ -76,6 +76,15 @@ pub struct WasmExtension { _task: Arc>>, } +impl Drop for WasmExtension { + fn drop(&mut self) { + // Only close the channel when this is the last clone holding the sender + if Arc::strong_count(&self.tx) == 1 { + self.tx.close_channel(); + } + } +} + #[async_trait] impl extension::Extension for WasmExtension { fn manifest(&self) -> Arc { @@ -670,7 +679,7 @@ impl WasmHost { Ok(WasmExtension { manifest, work_dir, - tx, + tx: Arc::new(tx), zed_api_version, _task: task, })