diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 637033c1d0..9bd7b68917 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -2031,7 +2031,7 @@ describe.each([ describe("Formula JS protection", () => { it("should time out JS execution if a single cell takes too long", async () => { - await config.withEnv({ JS_PER_EXECUTION_TIME_LIMIT_MS: 20 }, async () => { + await config.withEnv({ JS_PER_INVOCATION_TIMEOUT_MS: 20 }, async () => { const js = Buffer.from( ` let i = 0; @@ -2071,7 +2071,7 @@ describe.each([ it("should time out JS execution if a multiple cells take too long", async () => { await config.withEnv( { - JS_PER_EXECUTION_TIME_LIMIT_MS: 20, + JS_PER_INVOCATION_TIMEOUT_MS: 20, JS_PER_REQUEST_TIME_LIMIT_MS: 40, }, async () => { diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 0e94b65df8..7c3e8751c5 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -71,8 +71,8 @@ const environment = { SELF_HOSTED: process.env.SELF_HOSTED, HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT, FORKED_PROCESS_NAME: process.env.FORKED_PROCESS_NAME || "main", - JS_PER_EXECUTION_TIME_LIMIT_MS: - parseIntSafe(process.env.JS_PER_EXECUTION_TIME_LIMIT_MS) || 1000, + JS_PER_INVOCATION_TIMEOUT_MS: + parseIntSafe(process.env.JS_PER_INVOCATION_TIMEOUT_MS) || 1000, JS_PER_REQUEST_TIME_LIMIT_MS: parseIntSafe( process.env.JS_PER_REQUEST_TIME_LIMIT_MS ), diff --git a/packages/server/src/jsRunner/index.ts b/packages/server/src/jsRunner/index.ts index 67d5111ea6..60310585f5 100644 --- a/packages/server/src/jsRunner/index.ts +++ b/packages/server/src/jsRunner/index.ts @@ -18,7 +18,7 @@ export function init() { vm = new IsolatedVM({ memoryLimit: env.JS_RUNNER_MEMORY_LIMIT, - timeout: env.JS_PER_EXECUTION_TIME_LIMIT_MS, + invocationTimeout: env.JS_PER_INVOCATION_TIMEOUT_MS, perRequestLimit: env.JS_PER_REQUEST_TIME_LIMIT_MS, }) .withContext(ctxToPass) diff --git a/packages/server/src/jsRunner/vm/index.ts b/packages/server/src/jsRunner/vm/index.ts index 3e33abf99e..e8422e8f5d 100644 --- a/packages/server/src/jsRunner/vm/index.ts +++ b/packages/server/src/jsRunner/vm/index.ts @@ -47,7 +47,7 @@ export class IsolatedVM implements VM { private isolate: ivm.Isolate private vm: ivm.Context private jail: ivm.Reference - private timeout: number + private invocationTimeout: number private perRequestLimit?: number private moduleHandler = new ModuleHandler() @@ -56,11 +56,11 @@ export class IsolatedVM implements VM { constructor({ memoryLimit, - timeout, + invocationTimeout, perRequestLimit, }: { memoryLimit: number - timeout: number + invocationTimeout: number perRequestLimit?: number }) { this.isolate = new ivm.Isolate({ memoryLimit }) @@ -72,7 +72,7 @@ export class IsolatedVM implements VM { [this.resultKey]: { out: "" }, }) - this.timeout = timeout + this.invocationTimeout = invocationTimeout this.perRequestLimit = perRequestLimit } @@ -155,7 +155,7 @@ export class IsolatedVM implements VM { throw new Error(`"${specifier}" import not allowed`) }) - script.evaluateSync({ timeout: this.timeout }) + script.evaluateSync({ timeout: this.invocationTimeout }) const result = this.getResult() return result diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts index 2f82fbd49a..fa0de87f69 100644 --- a/packages/server/src/utilities/scriptRunner.ts +++ b/packages/server/src/utilities/scriptRunner.ts @@ -10,7 +10,7 @@ class ScriptRunner { this.code = `(() => {${script}})();` this.vm = new IsolatedVM({ memoryLimit: env.JS_RUNNER_MEMORY_LIMIT, - timeout: JS_TIMEOUT_MS, + invocationTimeout: JS_TIMEOUT_MS, }).withContext(context) }