From 01e3fea0ac464489bf7664b679e3dfcd4b0ec595 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 4 Jul 2025 08:44:53 +0100 Subject: [PATCH] fix(gui-client): don't panic on existing session (#9779) Customer hit what seems to be a rare race condition where we try to connect whilst we already have a session. I don't know which state it is in so I am replacing it with a WARN log to learn more about this in Sentry in case it gets hit again. --- rust/client-shared/src/lib.rs | 3 ++- rust/gui-client/src-tauri/src/service.rs | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rust/client-shared/src/lib.rs b/rust/client-shared/src/lib.rs index bbfb32049..783f495ec 100644 --- a/rust/client-shared/src/lib.rs +++ b/rust/client-shared/src/lib.rs @@ -27,11 +27,12 @@ const PHOENIX_TOPIC: &str = "client"; /// /// A session is created using [`Session::connect`]. /// To stop the session, simply drop this struct. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Session { channel: UnboundedSender, } +#[derive(Debug)] pub struct EventStream { channel: Receiver, } diff --git a/rust/gui-client/src-tauri/src/service.rs b/rust/gui-client/src-tauri/src/service.rs index 641ee7dee..032c35e07 100644 --- a/rust/gui-client/src-tauri/src/service.rs +++ b/rust/gui-client/src-tauri/src/service.rs @@ -178,7 +178,7 @@ struct Handler<'a> { telemetry_refresh: tokio::time::Interval, } -#[derive(Default)] +#[derive(Default, Debug)] enum Session { /// We've launched `connlib` but haven't heard back from it yet. Creating { @@ -600,13 +600,13 @@ impl<'a> Handler<'a> { Ok(()) } - /// Connects connlib - /// - /// Panics if there's no Tokio runtime or if connlib is already connected. fn try_connect(&mut self, api_url: &str, token: SecretString) -> Result { let started_at = Instant::now(); - assert!(self.session.is_none()); + if !self.session.is_none() { + tracing::warn!(session = ?self.session, "Connecting despite existing session"); + } + let device_id = device_id::get_or_create().context("Failed to get-or-create device ID")?; let url = LoginUrl::client(