You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`memoryLimit`|`number`|`128`| Maximum heap memory for the QuickJS VM, in megabytes. |
105
106
|`timeout`|`number`|`30000`| Maximum wall-clock time per execution, in milliseconds. |
106
107
|`maxStackSize`|`number`|`524288`| Maximum call stack size in bytes (default: 512 KiB). Increase for deeply recursive code; decrease to catch runaway recursion sooner. |
108
+
|`wasmLocation`|`string`| — | URL or path from which Emscripten loads the QuickJS WASM binary. When omitted, `quickjs-emscripten` resolves its bundled binary. |
109
+
110
+
### Serving the WASM binary
111
+
112
+
Set `wasmLocation` when the QuickJS WASM binary is hosted in a public directory or on a CDN:
Serve the synchronous release binary exported by `@jitl/quickjs-wasmfile-release-sync/wasm`. For a cross-origin URL, configure the host to allow cross-origin requests.
107
121
108
122
109
123
### How it works
110
124
111
-
QuickJS WASM uses an asyncified execution model — the WASM module can pause while awaiting host async functions (your tools). Executions are serialized through a global queue to prevent concurrent WASM calls, which the asyncify model does not support. Fatal errors (memory exhaustion, stack overflow) are detected, the VM is disposed, and a structured error is returned. Console output is captured and returned with the result.
125
+
QuickJS runs the synchronous WASM build and bridges host async functions (your tools)through QuickJS promises, avoiding suspension of the WASM stack. Fatal errors (memory exhaustion, stack overflow) are detected, the VM is disposed, and a structured error is returned. Console output is captured and returned with the result.
112
126
113
127
> **Performance note:** QuickJS interprets JavaScript rather than JIT-compiling it, so compute-heavy scripts run slower than with the Node driver. For typical LLM-generated scripts that are mostly waiting on `external_*` tool calls, this difference is not significant.
-`maxStackSize` — Default QuickJS runtime max stack size in bytes (default: 524288)
35
+
-`wasmLocation` — Optional URL or path from which Emscripten loads the QuickJS WASM binary. When omitted, `quickjs-emscripten` resolves its bundled binary.
36
+
37
+
## Serving the WASM Binary
38
+
39
+
Use `wasmLocation` when your runtime requires the QuickJS WASM binary to be served from a public directory or CDN:
The configured file must be the synchronous release binary exported by `@jitl/quickjs-wasmfile-release-sync/wasm`. Ensure cross-origin requests are allowed when serving it from another origin.
Uses [QuickJS](https://bellard.org/quickjs/) compiled to WebAssembly via [`quickjs-emscripten`](https://github.com/nicolo-ribaudo/quickjs-emscripten). Each execution creates a fresh async QuickJS context with tool bindings injected as global async functions.
61
+
Uses [QuickJS](https://bellard.org/quickjs/) compiled to WebAssembly via [`quickjs-emscripten`](https://github.com/nicolo-ribaudo/quickjs-emscripten). Each execution creates a fresh QuickJS context with tool bindings injected as global async functions.
0 commit comments