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

Make stream client closers non-blocking #791

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

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Oct 28, 2024

This updates the behavior of the streaming client methods BidiStreamForClient.CloseResponse and ServerStreamForClient.Close to be non-blocking, aligning it with the standard behavior of net/http's Request.Body closure.

Previously, the implementation used a graceful, blocking closure that fully read from the stream before closing. This allows for reuse of the underlying TCP connection. However, this behavior could lead to unexpected client hangs, as users may not anticipate blocking on close.

To address this, the closers no longer drain the stream. Documentation has been updated to clarify the behavior and provide users a workaround to keep the optimization by calling receive until the stream is drained. This avoids unexpected blocking behavior in client applications.

Fixes #789

This updates the behavior of the client streaming methods
`BidiStreamForClient.CloseResponse` and `ServerStreamForClient.Close` to
be non-blocking, aligning it with the standard behavior of `net/http`'s
`Request.Body` closure.

Previously, the implementation used a graceful, blocking closure that
fully read from the stream before closing. This allows for reuse of the
underlying TCP connection. However, this behavior could lead to
unexpected client hangs, as users may not anticipate blocking on close.

To address this, the closers no long drain the stream. Documentation has
been updated to clarify the behavior and provide users a workaround to
keep the optimization by Receiving messages until the stream is drain.
This avoids unexpected blocking behavior in client applications.

Signed-off-by: Edward McFarlane <[email protected]>
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.

ServerStreamForClient.Close hangs forever
1 participant