From 372304760d3005a4f848d4b0a584f5649ae32240 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 20 May 2024 18:11:41 +0300 Subject: [PATCH] Don't print empty goja stacktraces on captured panics This has been broken for years after some goja refactoring. There doesn't seem to be a way for this to be fixed without a lot of boilerplate all over the code. And this functionality has not been used in the last few years in my experience. closes #1906 --- js/common/util.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/js/common/util.go b/js/common/util.go index d1d01e06b0e..90b95e7cadd 100644 --- a/js/common/util.go +++ b/js/common/util.go @@ -65,21 +65,15 @@ func ToString(data interface{}) (string, error) { } // RunWithPanicCatching catches panic and converts into an InterruptError error that should abort a script -func RunWithPanicCatching(logger logrus.FieldLogger, rt *goja.Runtime, fn func() error) (err error) { +func RunWithPanicCatching(logger logrus.FieldLogger, _ *goja.Runtime, fn func() error) (err error) { defer func() { if r := recover(); r != nil { - gojaStack := rt.CaptureCallStack(20, nil) - err = &errext.InterruptError{Reason: fmt.Sprintf("a panic occurred during JS execution: %s", r)} // TODO figure out how to use PanicLevel without panicing .. this might require changing // the logger we use see // https://github.com/sirupsen/logrus/issues/1028 // https://github.com/sirupsen/logrus/issues/993 - b := new(bytes.Buffer) - for _, s := range gojaStack { - s.Write(b) - } - logger.Error("panic: ", r, "\n", string(debug.Stack()), "\nGoja stack:\n", b.String()) + logger.Error("panic: ", r, "\n", string(debug.Stack())) } }()