Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/bruno-js/src/sandbox/quickjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ const { marshallToVm } = require('./utils');
const addCryptoUtilsShimToContext = require('./shims/lib/crypto-utils');
const { wrapScriptInClosure, SANDBOX } = require('../../utils/sandbox');

let QuickJSSyncContext;
let QuickJSModule;
const loader = memoizePromiseFactory(() => newQuickJSWASMModule());
const getContext = (opts) => loader().then((mod) => (QuickJSSyncContext = mod.newContext(opts)));
getContext();
loader().then((mod) => (QuickJSModule = mod));

const toNumber = (value) => {
const num = Number(value);
Expand Down Expand Up @@ -57,7 +56,7 @@ const executeQuickJsVm = ({ script: externalScript, context: externalContext, sc
externalScript = removeQuotes(externalScript);
}

const vm = QuickJSSyncContext;
const vm = QuickJSModule.newContext();

try {
const { bru, req, res, ...variables } = externalContext;
Expand Down Expand Up @@ -97,7 +96,7 @@ const executeQuickJsVmAsync = async ({ script: externalScript, context: external
externalScript = externalScript?.trim();

try {
const module = await newQuickJSWASMModule();
const module = await loader();
const vm = module.newContext();

// add crypto utilities required by the crypto-js library in bundledCode
Expand Down
Loading