Skip to content

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

@Timmmm

Description

@Timmmm

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 ("Run the program" doesn't add anything), and the return type is very unobvious: Result<Result<(), ()>>. Expanding the Results it's actually anyhow::Result<std::result::Result<(), ()>>.

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

  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<ExitStatus> surely?

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmtime:docsIssues related to Wasmtime's documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions