bytecodealliance / bytecodealliance/wasmtime

wasmtime_wasi call_run() return type is weird and undocumented and doesn't provide access to the exit code

Open
#10,767 10 comments 0 reactions 0 assignees View on GitHub
wasmtime:docs
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

I'm running a WASM module like this:

let result_result = command.wasi_cli_run().call_run(&mut store).await;

`call_run()` is unfortunately [completely undocumented](https://docs.rs/wasmtime-wasi/latest/wasmtime_wasi/bindings/exports/wasi/cli/run/struct.Guest.html#method.call_run) ("Run the program" doesn't add anything), and the return type is very unobvious: `Result>`. Expanding the `Result`s it's actually `anyhow::Result>`.

So I think there are two sources of possible error from this run, which probably explains the nested `Result`s:

1. Some kind of error loading the module or with the bytecode or whatever.
2. The module returns a non-zero exit code.

I assumed that the *inner* `Result<(), ()>` would handle the latter case, but actually non-zero exit codes result in the *outer* `anyhow::Result<>` containing the error.

That's very surprising and kind of awkward because there's no way to access the exit code either. I would have expected a return type of `anyhow::Result` surely?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.