Failed to instantiate the example world by component model
Test Case
package component:matrix;
interface service {
enum flame-error {
internal,
}
type task-input = list<u8>;
type task-output = list<u8>;
record session-context {
session-id: string,
common-data: option<list<u8>>,
}
record task-context {
task-id: string,
session-id: string,
}
// handle request function
on-session-enter: func(ctx: session-context) -> result<_, flame-error>;
on-session-leave: func(ctx: session-context) -> result<_, flame-error>;
on-task-invoke: func(ctx: task-context, input: option<task-input>) -> result<option<task-output>, flame-error>;
}
// exports the interface
world flame {
export service;
}
Steps to Reproduce
- build wasm
cargo component build -p matrix-server - build wasm main
cargo build -p matrix-local - run wasm main
./target/debug/matrix-local
References:
- matrix-local: https://github.com/xflops/flame/pull/75/files#diff-448546749b6625cbca1a43c400f6d86637db5f014968c96ece09705e07f65c7c
- matrix-server (wasm): https://github.com/xflops/flame/pull/75/files#diff-e21ed78fa8d569631fed0fdddc6c99d585fc4d25806da0c7c00c4ebb2bacc8e9
Expected Results
Execute the callbacks accordingly, e.g. on_session_enter.
Actual Results
$ ./target/debug/matrix-local
Error: Internal("Failed to instantiate the flame world")
Versions and Environment
Wasmtime version or commit:
wasmtime = "16"
wasmtime-wasi = "16"
anyhow = "1"
$ rustc --version
rustc 1.74.1 (a28077b28 2023-12-04)
$ cargo --version
cargo 1.74.1 (ecb9851af 2023-10-18)
Operating system: Ubuntu 22.04
Architecture: x86
The same issue with the add example:
$ ./target/debug/host-add
Error: Failed to instantiate the example world
Caused by:
0: import `wasi:cli/[email protected]` has the wrong type
1: instance export `get-environment` has the wrong type
2: expected func found nothing
It works when rollback to wasmtime 15.
Thanks for the report! This is probably due to a missing add_to_linker somewhere to register WASI with the linker. Do you have a version of the code to read over which isn't a PR?
Just try it with 16.0, the issue should be there. The version 15 works for me, did not try the latest one.
Reference:
- WASM app: https://github.com/xflops/flame/tree/main/examples/matrix/server
- WASM engine: https://github.com/xflops/flame/blob/main/executor_manager/src/shims/wasm_shim.rs
When upgrading from wasmtime-wasi 15 to 16, the version numbers in the wit packages changed. I can't find it in your build, but wherever you are running wasm-tools component new (maybe you are using cargo-component?) you need to change the wasi preview 1 adapter to the version that ships with wasmtime 16 as well, which will match those wit packages.
wherever you are running
wasm-tools component new(maybe you are using cargo-component?) you need to change the wasi preview 1 adapter to the version that ships with wasmtime 16 as well
I don't quite understand. Could you be more specific about how to do this? I'm having this issue as well when running a modified version of one of the component model examples, and for me, switching to Wasmtime 15 did not fix the issue and I don't know how to proceed.