Stream: general

Topic: WASI optional methods


view this post on Zulip Ignatz (Jul 28 2026 at 12:16):

As far as I remember, there's no way to add new optional method to a WASI. Specifically, I'd like to update the interface and the host in a way that allows me to load and run old components and call new optional methods only when they exist on new components.

I vaguely remember that I used to follow a github issue but for the life of me, I cannot find it. Is this actually something on the roadmap or am I just hallucinating :woman_shrugging: ? :pray:

view this post on Zulip David Craven (Jul 28 2026 at 12:46):

@Ignatz if you expose the new methods as a new interface, you can instantiate it like this:

            let component =
                Component::from_binary(&engine, &bytes)?;
            let instance_pre = self
                .linker
                .instantiate_pre(&component)?;
            let indicesv1 =
                interfacev1::GuestIndices::new(&instance_pre).ok();
            let indicesv2 = interfacev2::GuestIndices::new(&instance_pre).ok();
            let mut store = Store::new(&engine, State::new());
            let instance = instance_pre
                .instantiate_async(&mut store)
                .await?;
            let guest_v1 = indicesv1.map(|indices| indices.load(&mut store, &instance))?;
            let guest_v2 = indicesv2.map(|indices| indices.load(&mut store, &instance))?;
            // do something with your Option<Guest>'s

view this post on Zulip Ignatz (Jul 28 2026 at 12:53):

That's very helpful :pray:. Do you happen to know if there's anything in flight for extending existing interfaces?

view this post on Zulip David Craven (Jul 28 2026 at 13:22):

I guess if the interface is versioned you can use the same approach to see if you can instantiate v1 or v2, but haven't tried it. don't have anything to do with wasmtime or wasi development, so no idea whats on the roadmap

view this post on Zulip Ignatz (Jul 28 2026 at 14:39):

Appreciated. IIUC, by versioning you mean versioning them with different names, e.g. IFv2? Otherwise you may end up with host-binary linker issues, e.g. having multiple versions of the generated bindings

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:10):

Wit packages have optional versioning built in, and wasmtime will use semver when resolving names https://component-model.bytecodealliance.org/design/wit.html#packages

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:12):

So you can have a guest that imports methods from your package@0.1.0, and your host can add a

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:12):

Method and call that version of the wit 0.1.1, and add the 0.1.1 bindings to the Linker. The guest imports of 0.1.0 will resolve to the implementations in your linkers 0.1.1

view this post on Zulip Ignatz (Jul 28 2026 at 15:12):

My problem is with guest exports. The host rejects guests that don't have a new method

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:13):

Ah, yes, that’s a valid use case but wit and wasmtime don’t have first class support for that (yet. It’s a known thing that we would like to support one day…)

view this post on Zulip Ignatz (Jul 28 2026 at 15:14):

ack, that's my understanding as well. I felt I had seen a tracking bug in the past...

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:14):

So for that case you need to use Instance.get_export yourself and then cast the func to the right types,

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:14):

Yeah I’m on my phone and can’t find it easily but it’s somewhere

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

So for that case you need to use Instance.get_export yourself and then cast the func to the right types,

Basically not use bindgen, IIUC?

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:16):

Yeah bindgen isn’t set up to help with this

view this post on Zulip Ignatz (Jul 28 2026 at 15:16):

Pat Hickey said:

Yeah I’m on my phone and can’t find it easily but it’s somewhere

No worries and thanks for the help. If you find a reference later, I'd appreciate it. I'm pretty happy that I didn't hallucinate and even more importantly that it is on the roadmap

view this post on Zulip Pat Hickey (Jul 28 2026 at 15:17):

Bindgen could probably find some way to support it before it’s formalized in wit, and also the overall systemic issue could move forward, it’s just a matter of someone motivated driving either/both.

view this post on Zulip David Craven (Jul 28 2026 at 15:25):

I just explained how to do it, how does it not meet the requirements? the world just instantiates all the interfaces, instead of relying on the world, just instantiate the interfaces you care about manually, and handle when they aren't available

view this post on Zulip Ignatz (Jul 28 2026 at 15:31):

David Craven said:

I just explained how to do it, how does it not meet the requirements? the world just instantiates all the interfaces, instead of relying on the world, just instantiate the interfaces you care about manually, and handle when they aren't available

I guess your original example has two separate modules/bindings with interfacev1 & interfacev2. I would prefer not to managed multiple almost identical WIT definitions (since semantic versioning can't help here). Maybe I'm just misunderstanding


Last updated: Jul 29 2026 at 05:03 UTC