From b5f25da5ac07c19ca690ae801d401d0a50651dad Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 13 Dec 2024 16:52:34 +1100 Subject: [PATCH] fix(gui-client): remove error about unexpected `TunnelReady` (#7497) The communication between the GUI client, the IPC service and `connlib` are asynchronous. As such, it may happen that the state machines run out of sync. Receiving a `TunnelReady` despite not being in the right state for that is no concern and can be handled gracefully. --- rust/gui-client/src-common/src/controller.rs | 24 ++++++++------------ 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/rust/gui-client/src-common/src/controller.rs b/rust/gui-client/src-common/src/controller.rs index 282f117db..2f0543cf1 100644 --- a/rust/gui-client/src-common/src/controller.rs +++ b/rust/gui-client/src-common/src/controller.rs @@ -598,21 +598,17 @@ impl<'a, I: GuiIntegration> Controller<'a, I> { Err(Error::IpcServiceTerminating)? } IpcServerMsg::TunnelReady => { - if self.auth.session().is_none() { - // This could maybe happen if the user cancels the sign-in - // before it completes. This is because the state machine - // between the GUI, the IPC service, and connlib isn't perfectly synced. - tracing::error!("Got `TunnelReady` while signed out"); + let Status::WaitingForTunnel { start_instant } = self.status else { + // If we are not waiting for a tunnel, continue. return Ok(ControlFlow::Continue(())); - } - if let Status::WaitingForTunnel { start_instant } = self.status { - tracing::info!(elapsed = ?start_instant.elapsed(), "Tunnel ready"); - self.status = Status::TunnelReady { resources: vec![] }; - self.integration.show_notification( - "Firezone connected", - "You are now signed in and able to access resources.", - )?; - } + }; + + tracing::info!(elapsed = ?start_instant.elapsed(), "Tunnel ready"); + self.status = Status::TunnelReady { resources: vec![] }; + self.integration.show_notification( + "Firezone connected", + "You are now signed in and able to access resources.", + )?; self.refresh_system_tray_menu(); } }