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

[release/6.0] Do not flush serializer buffers before first IAsyncEnumerable element is fetched #59865

Merged
merged 3 commits into from
Oct 4, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 1, 2021

Backport of #59808 to release/6.0

/cc @eiriktsarpalis

Customer Impact

The current STJ implementation of IAsyncEnumerable<T> serialization will attempt to flush the serializer's internal buffer to the underlying stream every time an IAsyncEnumerator.MoveNextAsync() call yields a running task. This is by design behavior, intended to echo the chunking strategy employed by the IAsyncEnumerable source.

Note however that many IAsyncEnumerable<T> implementations that wrap over network connections will delay establishing a connection until the first IAsyncEnumerator.MoveNextAsync() has been made. Thus in scenaria where establishing a connection has failed, the serializer will have already flushed data to the underlying stream, in a some cases preventing users from performing necessary error recovery. This is a customer reported issue.

This PR changes the buffer flushing logic so that the first MoveNextAsync() does not prompt flushing of serializer buffers.

Testing

Unit testing has been added that validates the new behavior.

Risk

Low. Applies minor interventions to product code to modify the buffer flushing logic.

cc @pranavkm @davidfowl

@ghost
Copy link

ghost commented Oct 1, 2021

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #59808 to release/6.0

/cc @eiriktsarpalis

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Oct 1, 2021
@eiriktsarpalis eiriktsarpalis self-assigned this Oct 1, 2021
@Anipik Anipik merged commit 87383db into release/6.0 Oct 4, 2021
@eiriktsarpalis eiriktsarpalis deleted the backport/pr-59808-to-release/6.0 branch October 4, 2021 17:42
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants