A typescript package to execute JavaScript and TypeScript code in a webassembly quickjs sandbox
If async function called on the host and it throws an error (rejects promise ) The whole node dies with WASM dump error. Minimal example: ```typescript import { type SandboxOptions, loadQuickJs } from '@sebastianwessel/quickjs' const getData = async (input: string) => { throw new Error('test') } const options:SandboxOptions = { allowFetch: false, env: { getExternalData: getData, }, } const code = ` const fn = async ()=>{ const data = await env.getExternalData('some-id') return data.myValue } export default await fn() ` const quickjs= await loadQuickJs() const result = await quickjs.runSandboxed(async ({ evalCode }) => evalCode(code), options) console.log(result) ``` When I run it, i see: ``` $ tsx quickjs.ts Aborted(Assertion failed: list_empty(&rt->gc_obj_list), at: ../../vendor/quickjs-ng/quickjs.c,1954,JS_FreeRuntime) /home/sergii/work/zolar-assistant/node_modules/@jitl/quickjs-ng-wasmfile-release-sync/dist/emscripten-module.mjs:15 function M(a){c.onAbort?.(a);a="Aborted("+a+")";B(a);D=!0;E=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");f(a);throw a;}var ma=a=>a.startsWith("data:application/octet-stream;base64,"),A=a=>a.startsWith("file://"),N;function na(a){if(a==N&&C)return new Uint8Array(C);if(z)return z(a);throw"both async and sync fetching of the wasm failed";}function oa(a){return C?Promise.resolve().then(()=>na(a)):y(a).then(b=>new Uint8Array(b),()=>na(a))} ^ RuntimeError: Aborted(Assertion failed: list_empty(&rt->gc_obj_list), at: ../../vendor/quickjs-ng/quickjs.c,1954,JS_FreeRuntime). Build with -sASSERTIONS for more info. at M (/home/sergii/work/zolar-assistant/node_modules/@jitl/quickjs-ng-wasmfile-release-sync/dist/emscripten-module.mjs:15:65) at b (/home/sergii/work/zolar-assistant/node_modules/@jitl/quickjs-ng-wasmfile-release-sync/dist/emscripten-module.mjs:22:315) at wasm://wasm/001d15c2:wasm-function[661]:0x334d7 at wasm://wasm/001d15c2:wasm-function[919]:0x4d354 at QuickJSFFI.c._QTS_FreeRuntime (/home/sergii/work/zolar-assistant/node_modules/@jitl/quickjs-ng-wasmfile-release-sync/dist/emscripten-module.mjs:30:95) at _Lifetime.disposer (/home/sergii/work/zolar-assistant/node_modules/quickjs-emscripten-core/src/module.ts:336:16) at _Lifetime.dispose (/home/sergii/work/zolar-assistant/node_modules/quickjs-emscripten-core/src/lifetime.ts:177:12) at _Scope.dispose (/home/sergii/work/zolar-assistant/node_modules/quickjs-emscripten-core/src/lifetime.ts:341:18) at QuickJSRuntime.dispose (/home/sergii/work/zolar-assistant/node_modules/quickjs-emscripten-core/src/runtime.ts:130:23) at _Scope.dispose (/home/sergii/work/zolar-assistant/node_modules/quickjs-emscripten-core/src/lifetime.ts:341:18) Node.js v22.10.0 ``` I also see this message if a timeout happens during host function running (waiting) Distributor ID: Linuxmint Description: Linux Mint 20.2 Release: 20.2 Codename: uma "@jitl/quickjs-ng-wasmfile-release-sync": "^0.31.0", "@sebastianwessel/quickjs": "^2.1.1",
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by sergii-kamenskyi and has received 1 comments.