From 513a6f9ec7b19ebc5571bd28ab045c13c39d8da5 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 21 Feb 2025 00:13:24 +0700 Subject: [PATCH] cmd/cli: guarding against nil log ipc connection The log ip connection may be nil, since it was not created if blocked by firewall/VPN apps. While at it, also add warning when the ipc connection could not be created. --- cmd/cli/cli.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index a85e5f7..fcbf9b4 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -222,10 +222,16 @@ func run(appCallback *AppCallback, stopCh chan struct{}) { lc := &logConn{conn: conn} consoleWriter.Out = io.MultiWriter(os.Stdout, lc) p.logConn = lc + } else { + mainLog.Load().Warn().Err(err).Msgf("unable to create log ipc connection") } + } else { + mainLog.Load().Warn().Err(err).Msgf("unable to resolve socket address: %s", sockPath) } notifyExitToLogServer := func() { - _, _ = p.logConn.Write([]byte(msgExit)) + if p.logConn != nil { + _, _ = p.logConn.Write([]byte(msgExit)) + } } if daemon && runtime.GOOS == "windows" {