grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

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

Open andrewcostello opened this issue 3 years ago • 7 comments

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:

  • OS (e.g. from /etc/os-release): Android / React Native -->

andrewcostello avatar Mar 11 '21 03:03 andrewcostello

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.

watjurk avatar Mar 11 '21 07:03 watjurk

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

andrewcostello avatar Mar 11 '21 18:03 andrewcostello

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.

johanbrandhorst avatar Mar 12 '21 10:03 johanbrandhorst

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

HappyRainy avatar Feb 10 '22 21:02 HappyRainy

+1

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

leolusoli avatar Apr 14 '22 09:04 leolusoli

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

billyjacoby avatar Mar 21 '23 21:03 billyjacoby

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

johanbrandhorst avatar Mar 21 '23 22:03 johanbrandhorst