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
gRPC support #32
Comments
I have been working on a non-Cloudflare related Rust+Wasm project and ran into this same limitation. For whatever it's worth, I found https://github.com/titanous/grpc-web-client and was able to adapt the general concept to my particular use case, and given Cloudflare's direction in providing high-level wrapper APIs, it may be an interesting start. It does however bring in quite a lot of heavy dependencies, so to keep within the worker size limits, I'd wager an approach like pre-baking in a lot of that infrastructure into the underlying V8 isolate would be ideal. (This is coming from someone outside of Cloudflare making a ton of assumptions 🙂) |
I'd love to have support for full gRPC, but this project is not able to extend beyond the fundamental capabilities of the Workers runtime itself. Currently, it is able to proxy your gRPC connections, but not terminate and respond. I'll do some thinking on this, but for now I wouldn't expect much to happen in the near term. However, if you can tolerate using protobuf over http, you could surely decode a message from a request body and use it in a Rust worker. |
@jsievenpiper - ah i misread your comment at first. I'll take a stab at testing https://github.com/titanous/grpc-web-client soon! thanks for sharing |
Hi! May be this tonic-web-wasm-client ? |
I managed to use tonic-web-wasm-client from Workers after disabling credentials. diff --git a/src/call.rs b/src/call.rs
index 993dc40..e08c8cb 100644
--- a/src/call.rs
+++ b/src/call.rs
@@ -7,7 +7,7 @@ use http_body::Body;
use js_sys::{Array, Uint8Array};
use tonic::body::BoxBody;
use wasm_bindgen::JsValue;
-use web_sys::{Headers, RequestCredentials, RequestInit};
+use web_sys::{Headers, RequestInit};
use crate::{fetch::fetch, options::FetchOptions, Error, ResponseBody};
@@ -71,8 +71,7 @@ fn prepare_request(
init.method("POST")
.headers(headers.as_ref())
- .body(body.as_ref())
- .credentials(RequestCredentials::SameOrigin);
+ .body(body.as_ref());
web_sys::Request::new_with_str_and_init(url, &init).map_err(Error::js_error)
} |
Hi, |
This is a probably a very big task, since JS Workers don't seem to have an existing library or a nice way to do it. There are some existing crates like tonic which support gRPC but these likely wouldn't work without a lot of changes. gRPC also has streams, which some platforms don't support while still supporting unary requests (possibly for similar reasons that might prevent Workers from supporting them). gRPC-web might be easier, but do not currently support streams.
Another possible issue is Cloudflare's support for gRPC since HTTP/2 isn't just enabled for everything by default and Workers might not currently support HTTP/2(?).
The text was updated successfully, but these errors were encountered: