This commit is contained in:
Adria Navarro 2024-02-08 11:26:51 +01:00
parent d293abc8e8
commit d1d005dbbc
1 changed files with 4 additions and 8 deletions

View File

@ -205,8 +205,8 @@ export class IsolatedVM implements VM {
script.evaluateSync({ timeout: this.#timeout }) script.evaluateSync({ timeout: this.#timeout })
const result = this.#getResult() const result = this.#getFromContext(this.#resultKey)
return result return result.out
} }
#registerCallbacks(functions: Record<string, any>) { #registerCallbacks(functions: Record<string, any>) {
@ -241,13 +241,9 @@ export class IsolatedVM implements VM {
} }
#getFromContext(key: string) { #getFromContext(key: string) {
return this.#jail.getSync(key) const ref = this.#vm.global.getSync(key, { reference: true })
}
#getResult() {
const ref = this.#vm.global.getSync(this.#resultKey, { reference: true })
const result = ref.copySync() const result = ref.copySync()
ref.release() ref.release()
return result.out return result
} }
} }