Stream: general

Topic: [Need Help] add sync WIT function returning future


view this post on Zulip Ignatz (Jul 02 2026 at 15:00):

I'm probably holding it wrong, but after adding a new sync function returning a future, i.e.:

execute: func(query: string, params: list<value>) -> future<result<u64, tx-error>>;

, implementing it on the host-side using a FutureReader and rebuilding the rust guest component, I'm seeing:

Failed to instantiate WIT component "../../client/testfixture/wasm/wasm_guest_testfixture.wasm": 'component imports instance `tr
ailbase:database/sqlite@0.1.2`, but a matching implementation was not found in the linker'.
    This may happen if the server and component are ABI incompatible. Make sure to run compatible versions, i.e. update/rebuild the component to match the server binary or update your server t
o run more up-to-date components.
    First-party components can be updated easily by running `$ trail components update` or downloaded from: https://github.com/trailbaseio/trailbase/releases.

thread 'main' (1672464) panicked at crates/wasm-runtime-axum/examples/standalone.rs:52:10:
called `Result::unwrap()` on an `Err` value: Wasmtime(component imports instance `trailbase:database/sqlite@0.1.2`, but a matching implementation was not found in the linker

Caused by:
    0: instance export `execute` has the wrong type
    1: type mismatch with async
)

I suspect there's a disconnect between the host-side and guest-side "bindgen"...maybe :woman_shrugging:. Happy to provide more context :pray:

view this post on Zulip Joel Dice (Jul 02 2026 at 16:27):

How are you adding the host function to the linker? Are you using wasmtime-wit-bindgen or calling Linker::func_wrap_async or Linker::func_wrap_concurrent directly?

view this post on Zulip Ignatz (Jul 02 2026 at 17:15):

Simply calling the bindgen generated add_to_linker function: https://github.com/trailbaseio/trailbase/blob/wasip3/crates/wasm-runtime-host/src/lib.rs#L136 :pray:

view this post on Zulip Joel Dice (Jul 02 2026 at 18:06):

Yeah, it does seem like there's a mismatch between the host- and guest-side generated bindings in that one side thinks execute is an async function and the other side thinks it's a non-async function, which could happen if two, contradictory WIT definitions are used. Are you using recent versions of both Wasmtime and wit-bindgen and can you confirm that the same WIT file is being used on both sides?

view this post on Zulip Ignatz (Jul 02 2026 at 18:41):

Ack to everything. I'm using the latest versions of wasmtime and bindgen. The guest codegen is here: https://github.com/trailbaseio/trailbase/blob/wasip3/crates/wasm-runtime-guest/src/lib.rs#L6 and the host codegen is here: https://github.com/trailbaseio/trailbase/blob/wasip3/crates/wasm-runtime-host/src/host.rs#L50 (maybe me specifying the import flags is the issue?). Anyway, the WIT is the same and the function was just added (https://github.com/trailbaseio/trailbase/blob/wasip3/crates/wasm-runtime-guest/wit/trailbase/database/world.wit#L22), so if they'd use stale definitions i'd rather expect that one side is missing the stub :shrug:

view this post on Zulip Joel Dice (Jul 02 2026 at 18:47):

ok, I don't know offhand what's going wrong. Would you be able to provide a list of steps to repro the error message? If so, I can take a closer look.

view this post on Zulip Ignatz (Jul 02 2026 at 18:52):

That's very kind.

git clone https://github.com/trailbaseio/trailbase.git
cd trailbase
git checkout wasip3
cd crates/wasm-runtime-axum
cargo run --example standalone -- --path=../../client/testfixture/wasm

view this post on Zulip Ignatz (Jul 02 2026 at 19:13):

This loads prebuilt component checked in at <repo>/client/testfixture/wasm/wasm_guest_testfixture.wasm. The component lives here: <repo>/client/testfixture/guests/rust and can be rebuilt with:

cd <repo>/client/testfixture/guests/rust
make

view this post on Zulip Joel Dice (Jul 02 2026 at 19:15):

Thanks. Looks like this is a bug in Wasmtime 46 and earlier, fixed in https://github.com/bytecodealliance/wasmtime/commit/72403200a425788850a97c6d9730dc583135e673. If you try updating to Wasmtime's main branch, it should be fixed there.

view this post on Zulip Ignatz (Jul 03 2026 at 10:06):

:pray: I just tried and indeed the component can be loaded building the host from "main" - Thanks!


Last updated: Jul 29 2026 at 05:03 UTC