improbable-eng / grpc-web

gRPC Web implementation for Golang and TypeScript
Apache License 2.0
4.37k stars 435 forks source link

grpc on react-native server-side streaming RPCs (1 request N responses) only send response on close #905

Open andrewcostello opened 3 years ago

andrewcostello commented 3 years ago

Versions of relevant software used grpc-web v0.14.0

What happened GRPC stream requests made through React Native do not respond until the stream is closed.

What you expected to happen GRPC stream messages to be processed as they are received.

How to reproduce it (as minimally and precisely as possible): Add a sleep after stream.Send I added 5 seconds here. func (s *bookService) QueryBooks(bookQuery *pb_library.QueryBooksRequest, stream pb_library.BookService_QueryBooksServer) error { for _, book := range s.books { if strings.HasPrefix(s.book.Author, bookQuery.AuthorPrefix) { stream.Send(book) time.Sleep(time.Second * 5) } } return nil }

All books will only be received when the stream closes.

Tested this in the browser and messages are received as the server sends them. Full logs to relevant components

Environment:

watjurk commented 3 years ago

As far as I know, this is how it's intended to work. In browser with http transport the same thing happens, my only solution is to use websocket transport.

andrewcostello commented 3 years ago

We have long-running XHR requests on the web that do not function this way.

I will wait for confirmation that this is the intended result. Thank you

johanbrandhorst commented 3 years ago

It definitely should be possible to server-stream as-it-happens and not wait for the full result. It sounds like because this is working in the browser it has to be something about the react-native transport that's causing the issue. It was a contribution from @pbsf so maybe they know what's going on.

HappyRainy commented 2 years ago

We have the same issue for our server side streaming grpc service. Really hope it can be solved.

leolusoli commented 2 years ago

+1

This is an huge issue. In this current moment, the library is not usable for handle streams inside a react-native project.

billyjacoby commented 1 year ago

Just chiming in here that this is also affecting me and my company. Would love to find a solution to be able to consume streams from react-native

johanbrandhorst commented 1 year ago

Maybe try connect.build/? This repository is no longer actively maintained.