Setup error logging

This commit is contained in:
Adria Navarro 2024-02-12 14:01:00 +01:00
parent b27ca57e1a
commit 93eb9fc9c8
2 changed files with 9 additions and 2 deletions

View File

@ -97,6 +97,7 @@ const environment = {
APP_MIGRATION_TIMEOUT: parseIntSafe(process.env.APP_MIGRATION_TIMEOUT), APP_MIGRATION_TIMEOUT: parseIntSafe(process.env.APP_MIGRATION_TIMEOUT),
JS_RUNNER_MEMORY_LIMIT: JS_RUNNER_MEMORY_LIMIT:
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64, parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64,
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
} }
// threading can cause memory issues with node-ts in development // threading can cause memory issues with node-ts in development

View File

@ -1,7 +1,7 @@
import vm from "vm" import vm from "vm"
import env from "../environment" import env from "../environment"
import { setJSRunner } from "@budibase/string-templates" import { setJSRunner, setOnErrorLog } from "@budibase/string-templates"
import { context, timers } from "@budibase/backend-core" import { context, logging, timers } from "@budibase/backend-core"
import tracer from "dd-trace" import tracer from "dd-trace"
type TrackerFn = <T>(f: () => T) => T type TrackerFn = <T>(f: () => T) => T
@ -58,4 +58,10 @@ export function init() {
) )
}) })
}) })
if (env.LOG_JS_ERRORS) {
setOnErrorLog((error: Error) => {
logging.logWarn(JSON.stringify(error))
})
}
} }