Skip to content

feat(wasmtime-cli): enable async CM feature #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rvolosatovs
Copy link
Member

With this I was able to run:

mod bindings {
    wit_bindgen::generate!({
        world: "wasi:cli/command",
        async: {
            exports: [
                "wasi:cli/run@0.3.0#run",
            ],
        },
        generate_all,
    });

    use super::Component;

    export!(Component);
}

use bindings::wit_stream;
use futures::SinkExt as _;

struct Component;

impl bindings::exports::wasi::cli::run::Guest for Component {
    async fn run() -> Result<(), ()> {
        let (mut tx, rx) = wit_stream::new();
        bindings::wasi::cli::stdout::set_stdout(rx);
        tx.send(b"hello".into())
            .await
            .expect("failed to write to STDOUT");
        Ok(())
    }
}

built via:

$ cargo build --target wasm32-unknown-unknown --release
$ wasm-tools component new --skip-validation  ./target/wasm32-unknown-unknown/release/p3_cli.wasm -o component.wasm

Using the wasmtime binary built from this commit

@rvolosatovs rvolosatovs force-pushed the chore/wasmtime-async-support branch from 7f5207d to 2ac3e5d Compare March 4, 2025 16:18
@rvolosatovs rvolosatovs changed the title feat(wasmtime-run): run components exporting wasi:cli@0.3 feat(wasmtime-cli): enable async CM feature Mar 4, 2025
@rvolosatovs
Copy link
Member Author

looks like it's mutually exclusive with module support :/

@rvolosatovs
Copy link
Member Author

It appears that the error originates here

Self::check_bool(
component_model_async,
other.contains(F::CM_ASYNC),
"WebAssembly component model support for async lifts/lowers, futures, streams, and errors",
)?;
. Interestingly, "just" enabling async for wasmtime serve works fine, as was done in #58

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs rvolosatovs force-pushed the chore/wasmtime-async-support branch from 2ac3e5d to 523676e Compare April 17, 2025 15:33
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.

1 participant