Merge branch 'master' of github.com:Budibase/budibase into fix-context-in-js
This commit is contained in:
commit
3e21d97c47
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.20.0",
|
"version": "2.20.1",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -21,17 +21,22 @@ export function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const bbCtx = context.getCurrentContext()!
|
const bbCtx = context.getCurrentContext()
|
||||||
|
|
||||||
if (!bbCtx.vm) {
|
const vm = bbCtx?.vm
|
||||||
bbCtx.vm = new IsolatedVM({
|
? bbCtx.vm
|
||||||
memoryLimit: env.JS_RUNNER_MEMORY_LIMIT,
|
: new IsolatedVM({
|
||||||
invocationTimeout: env.JS_PER_INVOCATION_TIMEOUT_MS,
|
memoryLimit: env.JS_RUNNER_MEMORY_LIMIT,
|
||||||
isolateAccumulatedTimeout: env.JS_PER_REQUEST_TIMEOUT_MS,
|
invocationTimeout: env.JS_PER_INVOCATION_TIMEOUT_MS,
|
||||||
}).withHelpers()
|
isolateAccumulatedTimeout: env.JS_PER_REQUEST_TIMEOUT_MS,
|
||||||
|
}).withHelpers()
|
||||||
|
|
||||||
|
if (bbCtx) {
|
||||||
|
// If we have a context, we want to persist it to reuse the isolate
|
||||||
|
bbCtx.vm = vm
|
||||||
}
|
}
|
||||||
const { helpers, ...rest } = ctx
|
const { helpers, ...rest } = ctx
|
||||||
return bbCtx.vm.withContext(rest, () => bbCtx.vm!.execute(js))
|
return vm.withContext(rest, () => vm.execute(js))
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.message === "Script execution timed out.") {
|
if (error.message === "Script execution timed out.") {
|
||||||
throw new JsErrorTimeout()
|
throw new JsErrorTimeout()
|
||||||
|
|
Loading…
Reference in New Issue