Merge pull request #13070 from Budibase/remove-vm2-refs
Remove vm2 usage from script controllers
This commit is contained in:
commit
601c02a4ac
|
@ -1,10 +1,11 @@
|
|||
import { Ctx } from "@budibase/types"
|
||||
import { VM2 } from "../../jsRunner/vm"
|
||||
import { IsolatedVM } from "../../jsRunner/vm"
|
||||
|
||||
export async function execute(ctx: Ctx) {
|
||||
const { script, context } = ctx.request.body
|
||||
const runner = new VM2(context)
|
||||
const result = runner.execute(script)
|
||||
const runner = new IsolatedVM().withContext(context)
|
||||
|
||||
const result = runner.execute(`(function(){\n${script}\n})();`)
|
||||
ctx.body = result
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
import { serializeError } from "serialize-error"
|
||||
import env from "../environment"
|
||||
import { JsErrorTimeout, setJSRunner } from "@budibase/string-templates"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import {
|
||||
JsErrorTimeout,
|
||||
setJSRunner,
|
||||
setOnErrorLog,
|
||||
} from "@budibase/string-templates"
|
||||
import { context, logging } from "@budibase/backend-core"
|
||||
import tracer from "dd-trace"
|
||||
|
||||
import { BuiltInVM, IsolatedVM } from "./vm"
|
||||
|
||||
const USE_ISOLATED_VM = true
|
||||
|
@ -41,4 +47,12 @@ export function init() {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (env.LOG_JS_ERRORS) {
|
||||
setOnErrorLog((error: Error) => {
|
||||
logging.logWarn(
|
||||
`Error while executing js: ${JSON.stringify(serializeError(error))}`
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue