From 30571d2c15f7a7e521e9589c04f9145b2e899310 Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown Date: Mon, 16 Sep 2024 11:19:33 -0700 Subject: [PATCH] Capture stack in panic --- handler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index f3f524ac..25d4ca02 100644 --- a/handler.go +++ b/handler.go @@ -10,6 +10,7 @@ import ( "net/url" "os" "reflect" + "runtime/debug" "sync" "time" @@ -1117,7 +1118,8 @@ func invoke(ctx context.Context, sf ServableFunction, input *sdkrequest.Request) if _, ok := r.(step.ControlHijack); ok { return } - panickErr = fmt.Errorf("function panicked: %v", r) + stack := string(debug.Stack()) + panickErr = fmt.Errorf("function panicked: %v. stack:\n%s", r, stack) } }()