tonic-web-wasm-client
tonic-web-wasm-client copied to clipboard
Add `wasip2` support
This change enables calling unary RPCs and response streaming from binaries built for the wasm32-wasip2 target.
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?
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.
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 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?
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).