From 9bff0bc8d324c3efab215070906def3099f766da Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 1 Jul 2025 16:10:54 +0200 Subject: [PATCH] fix(gui-client): don't drop bootstrap logger early (#9763) The GUI client binary performs quite a few checks prior to setting up logging. In order to log at least something, we have a bootstrap logger config that logs to stdout based on the `RUST_LOG` env var. However, in the context of an error, the logger guard was dropped to early and therefore we couldn't actually see the error. To fix this, we pass a mutable `Option` in to `try_main` instead. This allows the function to drop the bootstrap logger once the real one is set up but also keep logging using the bootstrap logger in case of an error. --- .../src-tauri/src/bin/firezone-gui-client.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs b/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs index 4129e12a6..42a68453b 100644 --- a/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs +++ b/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs @@ -18,8 +18,8 @@ use tracing::subscriber::DefaultGuard; use tracing_subscriber::EnvFilter; fn main() -> ExitCode { - let bootstrap_log_guard = - firezone_logging::setup_bootstrap().expect("Failed to setup bootstrap logger"); + let mut bootstrap_log_guard = + Some(firezone_logging::setup_bootstrap().expect("Failed to setup bootstrap logger")); // Mitigates a bug in Ubuntu 22.04 - Under Wayland, some features of the window decorations like minimizing, closing the windows, etc., doesn't work unless you double-click the titlebar first. // SAFETY: No other thread is running yet @@ -30,7 +30,7 @@ fn main() -> ExitCode { let mut telemetry = Telemetry::default(); let rt = tokio::runtime::Runtime::new().expect("failed to build runtime"); - match try_main(&rt, bootstrap_log_guard, &mut telemetry) { + match try_main(&rt, &mut bootstrap_log_guard, &mut telemetry) { Ok(()) => { rt.block_on(telemetry.stop()); @@ -48,7 +48,7 @@ fn main() -> ExitCode { fn try_main( rt: &Runtime, - bootstrap_log_guard: DefaultGuard, + bootstrap_log_guard: &mut Option, telemetry: &mut Telemetry, ) -> Result<()> { let cli = Cli::parse(); @@ -105,7 +105,7 @@ fn try_main( .or(mdm_settings.log_filter.clone()) .unwrap_or_else(|| advanced_settings.log_filter.clone()); - drop(bootstrap_log_guard); + drop(bootstrap_log_guard.take()); let logging::Handles { logger: _logger,