tonic-web-wasm-client icon indicating copy to clipboard operation
tonic-web-wasm-client copied to clipboard

Add `wasip2` support

Open tomasol opened this issue 4 months ago • 5 comments

This change enables calling unary RPCs and response streaming from binaries built for the wasm32-wasip2 target.

tomasol avatar Jul 29 '25 20:07 tomasol

Thanks for working on this. I'm not sure if this crate is the right place to add support for this. Anyway, can you please add some tests?

devashishdxt avatar Jul 30 '25 11:07 devashishdxt

I wasn’t sure either, but started exploring it and ended up completing it. No pressure, totally understand if it’s not the right fit.I'll add tests running on wasmtime.

tomasol avatar Jul 30 '25 12:07 tomasol

The tests fit nicely, essentially I just replaced an annotation. The whole change that enables wasip2 is in call and it uses most of other modules like response_body, body_stream etc. Let me know if you have any concerns or questions!

tomasol avatar Jul 30 '25 17:07 tomasol

@tomasol Can a standard gRPC client run directly in a WASI environment?

I'm a little confused about why gRPC-Web would be necessary. I was under the impression that gRPC-Web is a workaround specifically for web browsers. Does WASI's networking model have similar constraints that prevent a standard gRPC implementation from working?

devashishdxt avatar Aug 03 '25 03:08 devashishdxt

gRPC proper isn't currently supported in WASI, see this issue for context. While it's technically possible to send gRPC messages over HTTP/1, that requires non-standard server configs.

Even once full support lands in WASI runtimes, a gRPC-Web library could still be useful. For example, a WASI app might want to target gRPC-Web to integrate with existing infrastructure (e.g., sharing a port already exposed for gRPC-Web traffic).

tomasol avatar Aug 03 '25 19:08 tomasol