From 7d20fdd5ea358899a3331fff6d1ddd85de5ca509 Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Tue, 9 Apr 2024 20:27:27 +0200 Subject: [PATCH] Log panics (#1818) --- client/internal/connect.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/internal/connect.go b/client/internal/connect.go index b50b3a62910..6b888c9cca8 100644 --- a/client/internal/connect.go +++ b/client/internal/connect.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "runtime" + "runtime/debug" "strings" "time" @@ -94,6 +95,12 @@ func runClient( relayProbe *Probe, wgProbe *Probe, ) error { + defer func() { + if r := recover(); r != nil { + log.Panicf("Panic occurred: %v, stack trace: %s", r, string(debug.Stack())) + } + }() + log.Infof("starting NetBird client version %s on %s/%s", version.NetbirdVersion(), runtime.GOOS, runtime.GOARCH) // Check if client was not shut down in a clean way and restore DNS config if required.