diff --git a/packages/server/src/jsRunner.ts b/packages/server/src/jsRunner.ts index 08816aad42..5d3face3d8 100644 --- a/packages/server/src/jsRunner.ts +++ b/packages/server/src/jsRunner.ts @@ -33,6 +33,15 @@ export function init() { } } + const global = bbCtx.jsContext.global + for (const [key, value] of Object.entries(ctx)) { + if (typeof value === "function") { + // Can't copy functions into the isolate, so we just ignore them + continue + } + global.setSync(key, new ivm.ExternalCopy(value).copyInto()) + } + const script = bbCtx.jsIsolate.compileScriptSync(js) return script.runSync(bbCtx.jsContext, { timeout: env.JS_PER_EXECUTION_TIME_LIMIT_MS,