From 741553ebd006b92a18008e80df6bb355ba818307 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sat, 2 Nov 2024 03:32:53 +1100 Subject: [PATCH] chore(windows): log error when creating named pipe fails (#7203) I looked into this because of https://firezone-inc.sentry.io/issues/6033906390. We only have a single event there, i.e. it seems to have succeeded on the 2nd attempt. Regardless, it would be useful to learn _why_ it failed. To do that, we include the original error in the log statement. --- .../src-common/src/deep_link/windows.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rust/gui-client/src-common/src/deep_link/windows.rs b/rust/gui-client/src-common/src/deep_link/windows.rs index fb2b16741..b1c48c9b9 100644 --- a/rust/gui-client/src-common/src/deep_link/windows.rs +++ b/rust/gui-client/src-common/src/deep_link/windows.rs @@ -4,6 +4,7 @@ use super::FZ_SCHEME; use anyhow::{Context, Result}; use firezone_bin_shared::BUNDLE_ID; +use firezone_logging::std_dyn_err; use secrecy::Secret; use std::{ io, @@ -68,23 +69,24 @@ async fn bind_to_pipe(pipe_path: &str) -> Result return Ok(server), - Err(super::Error::CantListen) => { - tracing::warn!("`create_pipe_server` failed, sleeping... (loop {i})"); + Err(e) => { + tracing::warn!( + error = std_dyn_err(&e), + "`create_pipe_server` failed, sleeping... (attempt {i}/{NUM_ITERS})" + ); tokio::time::sleep(Duration::from_secs(1)).await; } - Err(error) => Err(error)?, } } Err(super::Error::CantListen) } -fn create_pipe_server(pipe_path: &str) -> Result { +fn create_pipe_server(pipe_path: &str) -> io::Result { let mut server_options = named_pipe::ServerOptions::new(); server_options.first_pipe_instance(true); - let server = server_options - .create(pipe_path) - .map_err(|_| super::Error::CantListen)?; + let server = server_options.create(pipe_path)?; + Ok(server) }