Hi, I get a component file with this wit file
package mycomponent:remote@0.1.0;
interface myinterface {
myfunction: async func() -> result<string, string>;
world myworld {
export myinterface;
}}
I use wasip3 target to build it. Everything is fine
I call my component like
let mut linker = Linker::new(&self.engine);
wasmtime_wasi::p2::add_to_linker_async(&mut linker)?;
let wasi = WasiCtx::builder().build();
let state = ComponentRunStates {
wasi_ctx: wasi,
resource_table: ResourceTable::new(),
};
let mut store = Store::new(&self.engine, state);
let plugin_full_path = plugin_dir.display().to_string() + "/" + &plugin + ".wasm";
let component = Component::from_file(&self.engine, plugin_full_path)?;
let instance = linker.instantiate_async(&mut store, &component).await?;
let mut result = [Val::String(String::new())];
instance.get_func(&mut store, "myfunction" ) {
...
}
But get function is not found.
I miss something?
Maybe async fn are not yet supported?
You need to look up the myinterface export first, then get the myfunction export from that. Let me see if I can find an example.
Here's a example (although it doesn't involve an async-typed function): https://github.com/bytecodealliance/wasmtime/blob/8adf03d4557acaa8384ec084946614d3f87c39ff/tests/all/component_model/func.rs#L3645-L3650
Thanks will try when go back to office
get_exports_name name arg is instance name?
let instance_index = instance.get_export_index(&mut store, None, "i").unwrap(); //here
The last parameter to get_export_index is the exported instance name, yes. In the example I linked to, see the WAT component being used, which exports an instance named i which exports a function named new and a type named r.
How to get instance name?
I don't use wat component, so I instanciate through wasmtime and linker
If I use myinterface as instance naming, instance is not found
In the case of the WIT you posted above, I'd expect the instance name to be mycomponent:remote/myinterface@0.1.0. You can check for sure using e.g. wasm-tools print $your_wasm_file and looking at the exports near the bottom of the output.
Awesome it works as expected.
Thanks for the help !
I get another issue :
thread 'tokio-runtime-worker' (14529) panicked at src/plugins.rs:74:62:
called `Result::unwrap()` on an `Err` value: error while executing at wasm backtrace:
0: 0x50229 - cascette.wasm!abort
1: 0x488d4 - cascette.wasm!std[47f6073b99490d06]::sys::pal::wasi::helpers::abort_internal
2: 0x4934c - cascette.wasm!std[47f6073b99490d06]::process::abort
3: 0x4bc1a - cascette.wasm!__rustc[1e24dcc63095d017]::__rust_abort
4: 0x4b0ed - cascette.wasm!__rustc[1e24dcc63095d017]::__rust_start_panic
5: 0x4bbbf - cascette.wasm!__rustc[1e24dcc63095d017]::rust_panic
6: 0x4b631 - cascette.wasm!std[47f6073b99490d06]::panicking::panic_with_hook
7: 0x4b323 - cascette.wasm!std[47f6073b99490d06]::panicking::panic_handler::{closure#0}
8: 0x4b2b6 - cascette.wasm!std[47f6073b99490d06]::sys::backtrace::__rust_end_short_backtrace::<std[47f6073b99490d06]::panicking::panic_handler::{closure#0}, !>
9: 0x4bc53 - cascette.wasm!__rustc[1e24dcc63095d017]::rust_begin_unwind
10: 0x592e8 - cascette.wasm!core[b849f7044ded83d4]::panicking::panic_fmt
11: 0x242fa - cascette.wasm!js_sys[a79c64c7964765fd]::global::get_global_object::GLOBAL_THIS::init
12: 0x23e71 - cascette.wasm!js_sys[a79c64c7964765fd]::global::get_global_object
13: 0x23c53 - cascette.wasm!js_sys[a79c64c7964765fd]::global
14: 0x2393c - cascette.wasm!web_sys[e52c455de79da0e4]::window
15: 0xf6be - cascette.wasm!<cascette_protocol[2eb4d3558c719011]::cache::wasm::ProtocolCache>::get_storage
16: 0x106a2 - cascette.wasm!<cascette_protocol[2eb4d3558c719011]::cache::wasm::ProtocolCache>::new
17: 0xe2a1 - cascette.wasm!<cascette_protocol[2eb4d3558c719011]::client::RibbitTactClient>::new
18: 0x262d - cascette.wasm!cascette[5108c410898490c6]::exports::sparus::cascette::sparus::_export_regions_cabi::<cascette[5108c410898490c6]::CascetteComponent>::{closure#0}
19: 0xd5d3 - cascette.wasm!<wit_bindgen[7aa71dee9b763b42]::rt::async_support::FutureState>::callback
Caused by:
wasm trap: wasm `unreachable` instruction executed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I guess I use wrong function to call an async function? Or it's not yet implemented?
Last updated: Mar 23 2026 at 18:16 UTC