Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix a circular reference between Client and UserStore

Conrad Irwin34efb23bf61f
diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs
index dcab0e53942..122046827ac 100644
--- a/crates/client/src/user.rs
+++ b/crates/client/src/user.rs
@@ -146,7 +146,13 @@ impl UserStore {
}),
_maintain_current_user: cx.spawn(|this, mut cx| async move {
let mut status = client.status();
+ let weak = Arc::downgrade(&client);
+ drop(client);
while let Some(status) = status.next().await {
+ // if the client is dropped, the app is shutting down.
+ let Some(client) = weak.upgrade() else {
+ return Ok(());
+ };
match status {
Status::Connected { .. } => {
if let Some(user_id) = client.user_id() {