From 32fd4eb3ac4796cdb1aae45647459c0d78b0105f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 8 Apr 2022 14:41:56 +0200 Subject: [PATCH] Insert project id in connection's project during project registration ...in contrast to doing so during worktree registration. This fixes a randomized test failure which would panic because store invariants would be violated. This would happen when a peer disconnected before it had a chance to register a worktree because, when removing all the state associated with that peer upon disconnection, we would notice the registered project without however finding it in the peer's connection state. --- crates/server/src/rpc/store.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/server/src/rpc/store.rs b/crates/server/src/rpc/store.rs index 6f5252fecf..6c330c9c8b 100644 --- a/crates/server/src/rpc/store.rs +++ b/crates/server/src/rpc/store.rs @@ -244,6 +244,9 @@ impl Store { language_servers: Default::default(), }, ); + if let Some(connection) = self.connections.get_mut(&host_connection_id) { + connection.projects.insert(project_id); + } self.next_project_id += 1; project_id } @@ -266,9 +269,7 @@ impl Store { .or_default() .insert(project_id); } - if let Some(connection) = self.connections.get_mut(&project.host_connection_id) { - connection.projects.insert(project_id); - } + project.worktrees.insert(worktree_id, worktree); if let Ok(share) = project.share_mut() { share.worktrees.insert(worktree_id, Default::default());