k82cn added the bug label to Issue #7716.
k82cn opened issue #7716:
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
k82cn commented on issue #7716:
The same issue with the add example:
$ ./target/debug/host-add Error: Failed to instantiate the example world Caused by: 0: import `wasi:cli/environment@0.2.0-rc-2023-11-10` has the wrong type 1: instance export `get-environment` has the wrong type 2: expected func found nothing
k82cn commented on issue #7716:
It works when rollback to wasmtime
15
.
alexcrichton commented on issue #7716:
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?
k82cn commented on issue #7716:
Just try it with
16.0
, the issue should be there. The version15
works for me, did not try the latest one.Reference:
pchickey commented on issue #7716:
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.
zeeshanlakhani commented on issue #7716:
As mentioned in Zulip, I'm suffering from:
running 1 test thread 'test_crop_base64' panicked at homestar-wasm/tests/execute_wasm.rs:156:10: called `Result::unwrap()` on an `Err` value: WasmRuntime(import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type Caused by: 0: instance export `get-environment` has the wrong type 1: expected func found nothing
This happens when compiling my wasm wit-bindgen (version 0.16) code with wasi (it works fine with wasm32-unknown-known). I'm using the reactor version of wasi_snapshot_preview1.wasm from wasmtime 16 when running --adapt. Our runtime, which embeds wasmtime, has:
wasmparser = "0.118" wasmtime = { version = "16.0", default-features = false, features = [ "async", "component-model", "cranelift", "parallel-compilation", "pooling-allocator", "wat", ] } wasmtime-component-util = "16.0" wasmtime-wasi = { version = "16.0", default-features = false, features = [ "tokio", ] } wat = "1.0" wit-component = "0.19"
It fails on instantiation:
let instance = linker.instantiate_async(&mut store, &component).await?; I even removed any WASI bits from the component code, but just focused on targetting wasm32-wasi.
zeeshanlakhani deleted a comment on issue #7716:
As mentioned in Zulip, I'm suffering from:
running 1 test thread 'test_crop_base64' panicked at homestar-wasm/tests/execute_wasm.rs:156:10: called `Result::unwrap()` on an `Err` value: WasmRuntime(import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type Caused by: 0: instance export `get-environment` has the wrong type 1: expected func found nothing
This happens when compiling my wasm wit-bindgen (version 0.16) code with wasi (it works fine with wasm32-unknown-known). I'm using the reactor version of wasi_snapshot_preview1.wasm from wasmtime 16 when running --adapt. Our runtime, which embeds wasmtime, has:
wasmparser = "0.118" wasmtime = { version = "16.0", default-features = false, features = [ "async", "component-model", "cranelift", "parallel-compilation", "pooling-allocator", "wat", ] } wasmtime-component-util = "16.0" wasmtime-wasi = { version = "16.0", default-features = false, features = [ "tokio", ] } wat = "1.0" wit-component = "0.19"
It fails on instantiation:
let instance = linker.instantiate_async(&mut store, &component).await?; I even removed any WASI bits from the component code, but just focused on targetting wasm32-wasi.
AccessViolation95 commented on issue #7716:
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 wellI don't quite understand. Could you be more specific about how to do this? I'm having this issue as well, and for me, switching to Wasmtime 15 did not fix the issue and I don't know how to proceed.
AccessViolation95 edited a comment on issue #7716:
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 wellI 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.
Last updated: Nov 22 2024 at 16:03 UTC