Waiting without blocking, built in
WASI 0.3, ratified on 11 June 2026, adds native async to the Component Model. A function can be async, and streams and futures are built-in types. WASI 0.2, released in January 2024, did the same jobs with pollables and stream resources.
Today you run one component built against each version and see what changed.
By the end of this lesson
Note
I can tell a WASI 0.3 interface from a WASI 0.2 one and say what changed.
Key words
| Word | What it means | Example |
|---|---|---|
| Async function | a function the caller need not wait on | async func |
| Stream | values that arrive one after another | stream<u8> |
| Future | one value that arrives later | future<u32> |
| Pollable | WASI 0.2's handle for something to wait on | |
| Semantic version | a version written major.minor.patch | 0.3.0 |
The cells students fill in are left blank in this preview.
How WASI 0.2 waits: pollables
In WASI 0.2, reading a socket or a file gives an input-stream resource. To wait for bytes without freezing, the code asks the stream for a pollable and passes it to poll, which returns when something is ready.
Every interface that waits needs its own pollable, and every language has to wire them into its own async system by hand.
Run the component built for WASI 0.2
docker exec wasm wasmtime run --invoke 'ticking()' clock2.watShown here, not run. Press Start lab to type it into your own lab’s terminal.
Run the component built for WASI 0.3
docker exec wasm wasmtime run --invoke 'ticking()' clock3.watShown here, not run. Press Start lab to type it into your own lab’s terminal.
What WASI 0.3 changed
WASI 0.3 moves waiting into the Component Model itself. WIT can now say async func, stream<u8> and future<T>, so the runtime knows when a call is waiting and can run something else.
Interfaces get shorter. An HTTP handler becomes one async function that takes a request and returns a response. Wasmtime turned WASI 0.3 on by default in version 46; the option -S p3=n turns it off.
Worked example: one job in each version
| Job | WASI 0.2 | WASI 0.3 |
|---|---|---|
| Wait for bytes | input-stream, then a pollable and poll | read a stream<u8> |
| Sleep for a while | a pollable from the clock | an async function on the clock |
| Answer a web request | a handler and a response out-parameter | one async function, request in, response out |
| Run two calls at once | poll a list of pollables | the runtime runs async calls side by side |
The cells students fill in are left blank in this preview.
Turn WASI 0.3 off and run again
docker exec wasm wasmtime run -S p3=n --invoke 'ticking()' clock3.watShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think every WASI 0.2 component must be rebuilt once hosts move to 0.3. Wasmtime still provides the 0.2 interfaces beside the 0.3 ones, as the lab showed. A component needs rebuilding only to use async functions or streams.
Try it: two waits taking turns
import asyncio
async def fetch(name, steps):
# Each await hands control back, so the other task runs meanwhile.
for n in range(steps):
print(name, "is waiting, step", n + 1)
await asyncio.sleep(0)
return name + " done"
async def main():
results = await asyncio.gather(fetch("logs", 2), fetch("prices", 3))
print(results)
asyncio.run(main())
# Change 3 to 1. Which task finishes first now?