Stream: wasmtime

Topic: ✔ Wasmtime bindgen specify resource method as async


view this post on Zulip Ari Seyhun (Mar 19 2026 at 14:28):

Is it possible to specify a specific method in a resource be async with the wasmtime bindgen macro?

You can specify a function be exported as async in the host with the exports: { ... } syntax in the bindgen macro, but what if I only wanted a single method from a resource be async, while the rest is default?

interface effect-runner {
    resource effect-state {
        constructor() -> result<effect-state, error>;
        query: func() -> dcb-query;
        handle: func(event: stored-event) -> result<_, error>;
    }
}

I can mark handle as async with handle: async func(...) in the wit, but I think I'd prefer just make it async on the host side. Is this possible? I'm struggling with the syntax. What I have tried is this:

bindgen!({
    path: "../../wit/effect",
    world: "effect",
    imports: { default: tracing | trappable },
    exports: {
        "umari:effect/effect-runner#[method]effect-state.handle": async,
        "umari:effect/effect-runner.effect-state.handle": async,
    },
    with: {
        "umari:common": crate::wit::common,
        "umari:sqlite": crate::wit::sqlite,
        "wasi:http": wasmtime_wasi_http::bindings::http,
    }
});

Both don't work, with the following errors:

unused `exports` rules found: ["\"umari:effect/effect-runner#[method]effect-state.handle\": FunctionFlags(ASYNC)"]
unused `exports` rules found: ["\"umari:effect/effect-runner.effect-state.handle\": FunctionFlags(ASYNC)"]

Is this possible?

view this post on Zulip Ari Seyhun (Mar 19 2026 at 14:41):

Got it! It was umari:effect/effect-runner.[method]effect-state.handle. Not sure if this is documented somewhere that I just missed.

view this post on Zulip Notification Bot (Mar 19 2026 at 14:41):

Ari Seyhun has marked this topic as resolved.


Last updated: Mar 23 2026 at 16:19 UTC