Skip to content

wasiExec

wasiExec(opts): Promise<ExitCode>

Defined in: packages/runtime/src/wasm/wasi-exec.ts:90

Run a pre-compiled WASI module inside a fishbowl process.

Routes wasi_snapshot_preview1 syscalls directly to proc.fs via WasiHost — there is no MEMFS shadow layer. Handles both non-asyncified modules (direct _start()) and asyncified ones (driven by RawAsyncify.runLoop()). Exits cleanly when the guest calls proc_exit.

WasiExecOptions

See WasiExecOptions.

Promise<ExitCode>

The exit code returned by the program (or thrown via proc_exit).

Error if the module has no _start export and is not asyncified.

RawAsyncify may call memory.grow() inside its constructor to allocate the asyncify data buffer, which detaches the cached WasiMemory views. We rebind memory immediately after constructing RawAsyncify — before any WASI import is called.

import { wasiExec, getWasmApi } from '@fishnet/runtime/wasm'
const mod = await getWasmApi().compile(wasmBytes)
const code = await wasiExec({ wasmModule: mod, proc, args: proc.argv })