Skip to content

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

Merged
Anipik merged 3 commits into
release/6.0from
backport/pr-59808-to-release/6.0
Oct 4, 2021
Merged

[release/6.0] Do not flush serializer buffers before first IAsyncEnumerable element is fetched#59865
Anipik merged 3 commits into
release/6.0from
backport/pr-59808-to-release/6.0

Conversation

@github-actions

@github-actionsgithub-actionsBot commented Oct 1, 2021

Copy link
Copy Markdown
Contributor

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 firstMoveNextAsync() 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

ghost commented Oct 1, 2021

Copy link
Copy Markdown

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:-

@eiriktsarpaliseiriktsarpalis added this to the 6.0.0 milestone Oct 1, 2021
@eiriktsarpaliseiriktsarpalis self-assigned this Oct 1, 2021
@Anipik
Anipik merged commit 87383db into release/6.0Oct 4, 2021
@eiriktsarpalis
eiriktsarpalis deleted the backport/pr-59808-to-release/6.0 branch October 4, 2021 17:42
@ghostghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for freeto 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

@eiriktsarpalis@Anipik