Skip to content
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

@connectrpc/connect-web unlock client and bidi streaming in supported browsers #1375

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidfiala
Copy link

@davidfiala davidfiala commented Dec 30, 2024

As discussed in #669 (comment) this PR brings client-side streaming (client or bidi) to supported browsers in @connectrpc/connect-web. The behavior in Google's grpc-web appears to allow client-side streaming in supported browsers and has quirky behavior in unsupported ones (see linked comment for specifics). However, this PR aims to simplify the developer experience by immediately throwing if a client-side streaming RPC is started on an unsupported browser. I believe that this PR does not introduce any harm or backwards compatibility errors because the preexisting case was that all client-side streaming calls would throw. We only unlock the capability when possible, and effectively do not change the existing behavior for unsupported browsers.

Support browsers are known to include Chromium-based browsers. Unsupported browsers are known to include Firefox and Safari.

Previous error message: The fetch API does not support streaming request bodies
Revised to: The fetch API does not support streaming request bodies in this browser

Note that the logic to detect compatibility is following the Chrome Developer docs which explains the nuance around how/why it works: https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#feature_detection

There's an important caveat: Only half duplex support is available. So while bidi streams do work, you will not see server responses until after the client finishes sending its stream. Once the client finishes its iterator, all prior server responses are immediately sent. From that point on, if the server's iterator is still producing more responses, those will continue to stream in as per normal.

…r browsers which support it, such as Chromium-based browsers. All other browsers simply get an error thrown, which was the existing behavior before this commit.

Signed-off-by: David Fiala <davidfiala@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant