open-toast / protokt

Protobuf compiler and runtime for Kotlin
Apache License 2.0
155 stars 14 forks source link

Is Browser supported, or just Node? #202

Open pusolito opened 1 year ago

pusolito commented 1 year ago

I'm curious if this will work in the browser as well. I tried a simple app and get a lot of errors related to missing modules. My guess is that it is due to grpc-js really being grpc-node in that it seems intended only for Node and not Browser. Can you confirm if Browsers are expected to work?

andrewparmet commented 1 year ago

Serialization does work in the browser - the conformance tests aren't run there, but there are various unit tests that execute in headless Firefox in CI.

I haven't tried running grpc-js in the browser but the runtime in this project should work anywhere it works.

pusolito commented 1 year ago

Looks like grpc-js is not meant to work in the browser. Would you consider adding grpc-web support to enable this use case.

andrewparmet commented 1 year ago

Do you have an idea of what support for grpc-web would look like?

pusolito commented 1 year ago

It sounds like the folks on the gRPC-web project might be able to assist and they could better answer your questions about support. My guess is it wouldn't be too much different than the work you already did for the node version in the grpc-lite library.

andrewparmet commented 1 year ago

Looks standard - we'd need to support generating a browser-compatible stub: https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/tutorial.md#generate-protobuf-messages-and-service-client-stub

We're able to invoke the grpc-kotlin generator for JVM directly since it's written in Kotlin. It may be possible to invoke the grpc-web plugin via forking a process and mangling package names the same way we do for grpc-kotlin.

pusolito commented 11 months ago

Checking in to see if there is a planned timeline to incorporate this into the library.

andrewparmet commented 11 months ago

There is no planned timeline. Feel welcome to take a stab at an implementation, or I'll comment here if I begin significant work I wouldn't want to duplicate.