wapc-rs icon indicating copy to clipboard operation
wapc-rs copied to clipboard

`WapcHost` usage in async contexts

Open muse254 opened this issue 1 year ago • 8 comments

I'd like to request for WapcHost to have another implementation that can be used in async environments by the caller. I'm aware that execution of WebAssembly modules is single threaded.

No amount of ceremony helped sidestep this issue. Also redoing the implementation in project doesn't work because of private fields/methods accessed.

Here's what I settled for reference: https://github.com/muse254/wapc-rs/pull/1/files

The error related to this: (self holds WapcHost in it's fields)

error: future cannot be sent between threads safely
  --> harness-node/src/main.rs:50:5
   |
50 | /     pub(crate) async fn handler(
51 | |         &mut self,
52 | |         req: Request,
53 | |     ) -> HarnessResult<Response<Cursor<Vec<u8>>>> {
   | |_________________________________________________^
   |
   = note: `(dyn wapc::wapchost::traits::WebAssemblyEngineProvider + 'static)` doesn't implement `std::marker::Send`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send

muse254 avatar Jul 28 '24 09:07 muse254

@muse254 that's super nice. This is something I wanted to implement since a long time. I'll take a look at the drafted PR during this week.

flavio avatar Aug 05 '24 10:08 flavio

I looked into your draft PR, then I started working on the topic during the weekend.

The amount of changes to be done was massive. Everything seems to be working šŸ˜€ I’m going to open a PR in the next days

flavio avatar Aug 12 '24 20:08 flavio

I'll be looking forward to the next release. Thank you for the fast turnaround.

muse254 avatar Aug 13 '24 07:08 muse254

@muse254 take a look at the linked PR and let me know what do you think about it. I've also added examples

flavio avatar Aug 13 '24 14:08 flavio

Hey, it looks really fleshed out. I'll be trying it out to see if I have any issues to report

muse254 avatar Aug 13 '24 16:08 muse254

@flavio I've done some initial tests, and everything seems to be working well, at least for my use cases with WapcHostAsync and related functionality. I'm okay with the implementation as it is. Thanks again for the quick turnaround!

muse254 avatar Aug 13 '24 20:08 muse254

Hey, how's the review coming along. Saw that it's stale. @flavio

muse254 avatar Sep 02 '24 14:09 muse254

@muse254 I've pinged the other waPC maintainers on https://github.com/wapc/wapc-rs/pull/96

flavio avatar Sep 03 '24 08:09 flavio

@muse254: wasmtime-provider 2.0.0 and wapc 2.0.0 are now available on crates.io :partying_face:

flavio avatar Sep 24 '24 06:09 flavio

Awesome! Can't wait to start the upgrade šŸš€

muse254 avatar Sep 24 '24 07:09 muse254