wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Why are futures generated by wasm_bindgen not `Send`?

Open jplatte opened this issue 3 years ago • 3 comments

Summary

Why are futures generated with wasm-bindgen not Send? Is there a way to opt into Sendness? Currently, if one wants to use async-trait for wasm, one has to do this very ugly thing on trait and impl:

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]

Additional Details

This came up before in #2409, but I didn't want to bump an old closed issue.

jplatte avatar Mar 09 '22 14:03 jplatte

Anything related to JsValue is not-Send in WebAssembly, which is probably where this comes from.

alexcrichton avatar Mar 09 '22 15:03 alexcrichton

Is there anything that you can think of that could be done about that? Does Send even mean much of anything for wasm, browser targets in particular (maybe yes bc. of web workers)?

jplatte avatar Mar 09 '22 15:03 jplatte

Yes because of web workers it matters, and at this time I don't know of anything that can be done.

alexcrichton avatar Mar 10 '22 17:03 alexcrichton