diff --git a/beacon-chain/main.go b/beacon-chain/main.go index 57f0a13d6..edf90e23f 100644 --- a/beacon-chain/main.go +++ b/beacon-chain/main.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "runtime" + runtimeDebug "runtime/debug" golog "github.com/ipfs/go-log" joonix "github.com/joonix/log" @@ -123,6 +124,13 @@ func main() { return debug.Setup(ctx) } + defer func() { + if x := recover(); x != nil { + log.Errorf("Runtime panic: %v\n%v", x, string(runtimeDebug.Stack())) + panic(x) + } + }() + if err := app.Run(os.Args); err != nil { log.Error(err.Error()) os.Exit(1) diff --git a/validator/main.go b/validator/main.go index 6bc5bc320..5d4a642b0 100644 --- a/validator/main.go +++ b/validator/main.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "runtime" + runtimeDebug "runtime/debug" joonix "github.com/joonix/log" "github.com/prysmaticlabs/prysm/shared/cmd" @@ -152,6 +153,13 @@ contract in order to activate the validator client`, return nil } + defer func() { + if x := recover(); x != nil { + log.Errorf("Runtime panic: %v\n%v", x, string(runtimeDebug.Stack())) + panic(x) + } + }() + if err := app.Run(os.Args); err != nil { log.Error(err.Error()) os.Exit(1)