Stream: wasi

Topic: Is the wasip3 http implementation incomplete?


view this post on Zulip mainrs (Jun 05 2025 at 13:58):

I am trying to use the wasmtime-was-http implementation from the prototyping repository. I called wasmtime_wasi_http::p3::add_only_http_to_linker(&mut linker).unwrap();, yet my component that imports wasi::http::handler::handle and calls it to make outgoing http requests fails during instantiation, because said function is not found inside the linker. I use the exact same wit files as the repository: I copy-pasted them to make sure that the types match.

thread 'main' panicked at ugl-wasmtime/src/main.rs:3:31:
called `Result::unwrap()` on an `Err` value: component imports instance `wasi:http/handler@0.3.0-draft`, but a matching implementation was not found in the linker

Caused by:
    0: instance export `handle` has the wrong type
    1: function implementation is missing
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I've taken a look at the source code of the wasmtime implementation and only ever see the proxy would being used for bindgen. Is the usage of the handler interface not possible (yet) without having a component also export a handle function itself?

view this post on Zulip mainrs (Jun 05 2025 at 14:24):

I've taken a look at the generated source code of wasmtime-wasi-http and the wasmtime_wasi::p3::bindings::wasi::http::handler::add_to_linker function looks like this:

pub fn add_to_linker<T, D>(
                            linker: &mut wasmtime::component::Linker<T>,
                            host_getter: fn(&mut T) -> D::Data<'_>,
                        ) -> wasmtime::Result<()>
                        where
                            D: HostConcurrent,
                            for<'a> D::Data<'a>: Host,
                            T: 'static + Send,
                        {
                            let mut inst = linker
                                .instance("wasi:http/handler@0.3.0-draft")?;
                            inst.func_wrap_concurrent(
                                "[async]handle",
                                move |
                                    caller: &mut wasmtime::component::Accessor<T>,
                                    (arg0,): (wasmtime::component::Resource<Request>,)|
                                {
                                    wasmtime::component::__internal::Box::pin(async move {
                                        let accessor = &mut unsafe {
                                            caller.with_data(host_getter)
                                        };
                                        let r = <D as HostConcurrent>::handle(accessor, arg0).await;
                                        Ok((r?,))
                                    })
                                },
                            )?;
                            Ok(())
                        }

Which in my eyes should be correct and work. It even defines the exact same component name the error message mentions that is missing.


Last updated: Dec 06 2025 at 06:05 UTC