From 43a284283367d78726d3fd43f252eaa5ea085270 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 19 Feb 2024 21:04:33 +0100 Subject: [PATCH] Fix defaulting values --- packages/server/src/jsRunner/vm/isolated-vm.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/server/src/jsRunner/vm/isolated-vm.ts b/packages/server/src/jsRunner/vm/isolated-vm.ts index 12559df0b7..83a7646cfa 100644 --- a/packages/server/src/jsRunner/vm/isolated-vm.ts +++ b/packages/server/src/jsRunner/vm/isolated-vm.ts @@ -38,10 +38,9 @@ export class IsolatedVM implements VM { invocationTimeout?: number isolateAccumulatedTimeout?: number } = {}) { - memoryLimit = memoryLimit || environment.JS_RUNNER_MEMORY_LIMIT - invocationTimeout = memoryLimit || 1000 - - this.isolate = new ivm.Isolate({ memoryLimit }) + this.isolate = new ivm.Isolate({ + memoryLimit: memoryLimit || environment.JS_RUNNER_MEMORY_LIMIT, + }) this.vm = this.isolate.createContextSync() this.jail = this.vm.global this.jail.setSync("global", this.jail.derefInto()) @@ -51,7 +50,7 @@ export class IsolatedVM implements VM { [this.resultKey]: { [this.runResultKey]: "" }, }) - this.invocationTimeout = invocationTimeout + this.invocationTimeout = invocationTimeout || 1000 this.isolateAccumulatedTimeout = isolateAccumulatedTimeout }