Stream: general

Topic: minimal async streams example w/ WASI preview2 + Rust guest?


view this post on Zulip Louis Thibault (Jun 24 2025 at 15:35):

Hi all,

I'm trying to experiment with async streams in WASI preview2, specifically using this Wasmtime host example as a reference.

Unfortunately, I’ve run into a few roadblocks:

Context:
Here’s the core error I keep encountering during cargo fetch:

error: failed to select a version for `wasmtime-wasi`. ... required by package `wasip2-demo` versions that meet the requirements `^8.0.0` are: 8.0.1, 8.0.0 the package depends on `wasmtime-wasi` with features: `preview2` but those features do not exist in those versions.

Attempts to use the GitHub repo as a git dependency lead to:

error: failed to select a version for `wasmtime-wasi`. ... required by package `wasip2-demo` versions that meet the requirements `*` are: 35.0.0 the package depends on `wasmtime-wasi` with features: `preview2` but those features do not exist.

I’m feeling stuck and would appreciate any pointers or links to minimal working examples of:

Thanks very much in advance for any help, and apologies if I’ve missed something obvious!

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime

view this post on Zulip Ralph (Jun 24 2025 at 15:37):

@Yosh Wuyts do your async examples address this?

view this post on Zulip Yosh Wuyts (Jun 24 2025 at 16:10):

I think it should cover the Rust guest side, at least: https://github.com/bytecodealliance/sample-wasi-http-rust

An example `wasi:http` server component written in Rust - bytecodealliance/sample-wasi-http-rust

view this post on Zulip Louis Thibault (Jun 24 2025 at 16:18):

Thank you both so much!

view this post on Zulip Matt Parker (Jun 27 2025 at 12:23):

async is only implemented for rust currently, is that correct?

view this post on Zulip Yosh Wuyts (Jun 27 2025 at 12:27):

JS and C are definitely supported as well right now

view this post on Zulip Yosh Wuyts (Jun 27 2025 at 12:28):

For WASIp2 that is

view this post on Zulip Yosh Wuyts (Jun 27 2025 at 12:30):

For WASIp3 it is only Rust and C right now

view this post on Zulip Yosh Wuyts (Jun 27 2025 at 12:33):

I forget what the state of support is for other languages on p2. I believe tiny Go, C#, and Python may all have support too - but I'm not actually sure. Someone else might know

view this post on Zulip Yosh Wuyts (Jun 27 2025 at 12:37):

Here is an async JS sample: https://github.com/bytecodealliance/sample-wasi-http-js

An example `wasi:http` server component written in JavaScript - bytecodealliance/sample-wasi-http-js

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:02):

Note also that there are many examples in the Jco repository:

https://github.com/bytecodealliance/jco/tree/main/examples/components

"async" is supported on the host side (via JSPI), thanks to hard work of contributors like Calvin -- but right now work on P3 support for Jco is underway

JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:03):

So right now, all examples target preview2 and it's envisioning of I/O (wasi:io, etc) -- not the new world (stream<t>s, etc)

view this post on Zulip Matt Parker (Jun 27 2025 at 13:11):

is it that wit-bindgen doesn't support anything other than rust yet then? I tried using async in C# and it blew up with PlatformNotSupportedException. Perhaps thats a dotnet runtime issue? I'll be honest, wasm, wasi, WIT, WAT, WASI 0.2, 0.3 etc is a lot to keep track of, so apologies if I've got it completely wrong haha

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:12):

Yup, that's the case -- right now async on the guest side has the best support in Rust -- it's evolved hand-in-hand with the p3-prototyping repo

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:13):

But if you're new to Wasm + WASI + WIT, WAT, I'd suggest tarting with preview2 and getting some stuff going! :)

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:14):

Have you seen https://component-model.bytecodealliance.org/ ? Hopefully it's a helpful resource for you -- but you can build stuff on P2 right now, and it is possible to do asynchronous operations (wasi:io et all), it's just a bit more tedious than P3 -- P3 is going to be a huge improvement on many axes

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:15):

Some talks on this that are a great listen and cover a lot of P2, P3 and motivations:

YouTube - - YouTube

YouTube - - YouTube

YouTube - - YouTube

view this post on Zulip Matt Parker (Jun 27 2025 at 13:16):

Victor Adossi said:

But if you're new to Wasm + WASI + WIT, WAT, I'd suggest tarting with preview2 and getting some stuff going! :)

Yeah I've got a guest component and host working, and wac'ing them together (another three letter acronym :sweat_smile:) and running! Its pretty cool
image.png

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:16):

All the work is in the open and there is a ton of work going on right now being lead by Alex, Joel and others.

view this post on Zulip Matt Parker (Jun 27 2025 at 13:17):

Victor Adossi said:

Have you seen https://component-model.bytecodealliance.org/ ? Hopefully it's a helpful resource for you -- but you can build stuff on P2 right now, and it is possible to do asynchronous operations (wasi:io et all), it's just a bit more tedious than P3 -- P3 is going to be a huge improvement on many axes

I think I've ended up there, yeah :)

view this post on Zulip Matt Parker (Jun 27 2025 at 13:17):

Victor Adossi said:

Some talks on this that are a great listen and cover a lot of P2, P3 and motivations:

https://www.youtube.com/watch?v=mkkYNw8gTQg&list=PLP3xGl7Eb-4OtFH1tcQm6u7_LRED7-3rg&index=31

https://www.youtube.com/watch?v=tAACYA1Mwv4&t=9s&pp=ygUPbHVrZSBjb21wb25lbnRz

https://www.youtube.com/watch?v=phodPLY8zNE

Thanks for these!

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:17):

Awesome! Looks like you're already making great progress -- wac is a somewhat more "advanced" feature than it should be, but it's another hugely underrated bit of the component model -- composability being a huge feature

view this post on Zulip Matt Parker (Jun 27 2025 at 13:19):

The last few days I was curious about what the future of browsers could look like - imagine the browser wasm runtime exported a world with an interface for the DOM Apis, and components could use that to update the dom

view this post on Zulip Matt Parker (Jun 27 2025 at 13:19):

How cool would that be - no JS! :sweat_smile:

view this post on Zulip Matt Parker (Jun 27 2025 at 13:21):

I then spent a longgggg time trying to find if any browser exposes a c api for the DOM, with very little results haha

view this post on Zulip Victor Adossi (Jun 27 2025 at 13:42):

Oh you might like the excellent work of Mendy and co:

https://github.com/wasi-gfx/webidl2wit

Example in Jco:

https://github.com/bytecodealliance/jco/tree/main/examples/components/webidl-book-library
https://github.com/bytecodealliance/jco/tree/229a8408538cee77aefdfcf834cb8e32bd2d2ebc/packages/jco/test/fixtures/idl

Contribute to wasi-gfx/webidl2wit development by creating an account on GitHub.
JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco
JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip Matt Parker (Jun 27 2025 at 13:55):

Oh very cool! :)


Last updated: Dec 06 2025 at 05:03 UTC