From 31670ab3e1592d038558483c0a1eaa112a648e18 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Fri, 1 Sep 2023 11:16:28 +0300 Subject: [PATCH] log cron job errors --- plugins/jsvm/binds.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/jsvm/binds.go b/plugins/jsvm/binds.go index 39b0862e..8f512b3a 100644 --- a/plugins/jsvm/binds.go +++ b/plugins/jsvm/binds.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "io" "net/http" "os" @@ -112,10 +113,14 @@ func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) { pr := goja.MustCompile("", "{("+handler+").apply(undefined)}", true) err := scheduler.Add(jobId, cronExpr, func() { - executors.run(func(executor *goja.Runtime) error { + err := executors.run(func(executor *goja.Runtime) error { _, err := executor.RunProgram(pr) return err }) + + if err != nil && app.IsDebug() { + fmt.Println("[cronAdd] failed to execute cron job " + jobId + ": " + err.Error()) + } }) if err != nil { panic("[cronAdd] failed to register cron job " + jobId + ": " + err.Error())