Fix adding to context
This commit is contained in:
parent
2ffe3d7153
commit
c57ccbc046
|
@ -13,11 +13,16 @@ export function init() {
|
|||
|
||||
let { vm } = bbCtx
|
||||
if (!vm) {
|
||||
// Can't copy the native helpers into the isolate. We just ignore them as they are handled properly from the helpersSource
|
||||
const { helpers, ...ctxToPass } = ctx
|
||||
|
||||
vm = new IsolatedVM({
|
||||
memoryLimit: env.JS_RUNNER_MEMORY_LIMIT,
|
||||
timeout: env.JS_PER_EXECUTION_TIME_LIMIT_MS,
|
||||
perRequestLimit: env.JS_PER_REQUEST_TIME_LIMIT_MS,
|
||||
}).withHelpers()
|
||||
})
|
||||
.withContext(ctxToPass)
|
||||
.withHelpers()
|
||||
|
||||
bbCtx.vm = vm
|
||||
}
|
||||
|
|
|
@ -185,10 +185,12 @@ export class IsolatedVM implements VM {
|
|||
|
||||
private addToContext(context: Record<string, any>) {
|
||||
for (let key in context) {
|
||||
const value = context[key]
|
||||
this.jail.setSync(
|
||||
key,
|
||||
context[key]
|
||||
//new ivm.ExternalCopy(context[key]).copyInto({ release: true })
|
||||
typeof value === "function"
|
||||
? value
|
||||
: new ivm.ExternalCopy(value).copyInto({ release: true })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue