Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

refactor component model async host APIs#116

Merged
dicej merged 3 commits into
mainfrom
async-host-api-refactor
Apr 10, 2025
Merged

refactor component model async host APIs#116
dicej merged 3 commits into
mainfrom
async-host-api-refactor

Conversation

@dicej
Copy link
Copy Markdown
Collaborator

@dicej dicej commented Apr 9, 2025

The main idea here is to remove the Promise abstraction (which turned out to be leaky and awkward in practice, especially inside host functions) in favor of plain Futures to represent CM async operations like guest tasks and stream/future reads/writes.

Those Futures must be polled and/or .awaited from within the originating instance's event loop. That happens automatically inside host functions, but top-level code must use Instance::{run,run_with,spawn} to fulfil that requirement. If such a Future is polled outside the event loop, it will panic.

Copy link
Copy Markdown
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API changes look good to me, did not review the implementation

Comment thread crates/wasi-http/src/p3/host/types.rs
Comment thread crates/wasi-http/src/p3/proxy.rs
Comment thread crates/wasi-http/tests/all/p3/incoming.rs Outdated
The main idea here is to remove the `Promise` abstraction (which turned out to
be leaky and awkward in practice, especially inside host functions) in favor of
plain `Future`s to represent CM async operations like guest tasks and
stream/future reads/writes.

Those `Future`s must be polled and/or `.await`ed from within the originating
instance's event loop.  That happens automatically inside host functions, but
top-level code must use `Instance::{run,run_with,spawn}` to fulfil that
requirement.  If such a `Future` is polled outside the event loop, it will
panic.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej force-pushed the async-host-api-refactor branch from 147283b to a29bb6c Compare April 10, 2025 15:26
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej enabled auto-merge April 10, 2025 16:34
This regression was actually introduced back when I added waitable set support,
but due to how the tests were being run we didn't notice it until my latest
refactor.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej added this pull request to the merge queue Apr 10, 2025
Merged via the queue into main with commit 2d6ba48 Apr 10, 2025
44 checks passed
@alexcrichton alexcrichton deleted the async-host-api-refactor branch April 15, 2025 19:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants