Skip to content

Conversation

@lthibault
Copy link
Contributor

@lthibault lthibault commented Nov 21, 2025

🟢 Does what it says on the tin. default-kernel upgraded to an asyncio echo example.
I plan to re-introduce your guest module asap.

Add wasip2 1.0 and futures 0.3 as dependencies to enable WASI Preview 2
async stream APIs and AsyncRead/AsyncWrite trait implementations needed
for Cap'n Proto transports.
Replace synchronous echo with async implementation using WASI Preview 2
streams and polling. This enables non-blocking I/O that allows wasmtime
to yield back to the host's Tokio runtime at WASI function call boundaries.

Key changes:
- Implement AsyncStdin wrapper with poll_read using stream.subscribe()
  and poll::poll() for non-blocking reads
- Implement AsyncStdout wrapper with poll_write using blocking_write_and_flush()
- Replace LocalPool with manual future polling using noop_waker
- Fix EOF handling: return Poll::Ready(Ok(0)) when stream closes

This maintains AsyncRead/AsyncWrite trait implementations for Cap'n Proto
compatibility while preventing OS thread blocking.
Update documentation to reflect the async echo implementation using WASI
Preview 2 streams. Document the AsyncRead/AsyncWrite trait implementations
and their use for Cap'n Proto transports.
@lthibault lthibault requested a review from mikelsr November 21, 2025 23:24
@lthibault lthibault self-assigned this Nov 21, 2025
@lthibault lthibault changed the title Feat/guest wasip2 async Enable WASIP2 asyncio in guest Nov 21, 2025
Prefix unused cx parameter with underscore to silence compiler warning.
The parameter is required by the AsyncRead trait signature but not used
since WASI polling handles waiting internally.
Replace find-based file discovery with explicit reference to default_kernel.wasm
for better reliability and clarity. This ensures we always copy the correct
WASM file produced by cargo.
- Fix default-kernel README: replace 'pollster' with 'manual future polling with noop_waker'
- Update examples README: correct default-kernel description (async echo, not Cap'n Proto RPC)
- Update requirements: clarify that examples have different dependencies
- Update development guide: make ww dependency optional, clarify wasip2 feature usage
@lthibault lthibault marked this pull request as ready for review November 21, 2025 23:36
@mikelsr mikelsr merged commit 286caaa into master Nov 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants