wasmExec
wasmExec(
opts):Promise<ExitCode>
Defined in: packages/runtime/src/wasm/runtime.ts:97
Execute an Emscripten-compiled WASM program within a fishbowl process.
- Pre-load
preloadPathsfromproc.fsinto Emscripten’s MEMFS - Initialize the Emscripten module with env injected via
preRun - Run the program — raw TTY mode drives via the Asyncify bridge and
_main; line mode uses a pre-buffered synchronous stdin callback andcallMain - Sync modified and newly-created files from MEMFS back to
proc.fs - Return the program’s exit code
Parameters
Section titled “Parameters”See WasmExecOptions.
Returns
Section titled “Returns”Promise<ExitCode>
The program’s exit code.
Caveat
Section titled “Caveat”Emscripten reads ENV during preRun, not after module init —
env vars are injected via a preRun hook for this reason.
Caveat
Section titled “Caveat”module.locateFile is stubbed to return the input path unchanged,
preventing the glue from calling new URL(name, import.meta.url)
which fails when the glue is evaluated outside its original module
context (e.g. served from the HTTP registry and eval’d as CJS).
Caveat
Section titled “Caveat”In line mode, stdin is fully buffered before callMain because
Emscripten’s module.stdin callback is synchronous.
Example
Section titled “Example”const code = await wasmExec({ wasmBinary, glueFactory, proc, args: proc.argv, ttyMode: 'line'})