Memory limit via env

This commit is contained in:
Adria Navarro 2024-02-06 15:13:34 +01:00
parent 9a45017532
commit 0b0b6ddb13
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import ivm from "isolated-vm"
import bson from "bson"
import { BundleType, loadBundle } from "../jsRunner/bundles"
import env from "../environment"
const JS_TIMEOUT_MS = 1000
@ -9,7 +10,7 @@ class ScriptRunner {
vm: IsolatedVM
constructor(script: string, context: any) {
this.vm = new IsolatedVM({ memoryLimit: 64 })
this.vm = new IsolatedVM({ memoryLimit: env.JS_RUNNER_MEMORY_LIMIT })
this.vm.context = {
...context,
data: bson.BSON.serialize({ data: context.data }),