Fix a bug where we would not flush messages before waiting for a response#705
Merged
LukeButters merged 4 commits intomainfrom Mar 29, 2026
Merged
Fix a bug where we would not flush messages before waiting for a response#705LukeButters merged 4 commits intomainfrom
LukeButters merged 4 commits intomainfrom
Conversation
LukeButters
commented
Mar 26, 2026
| var serializedStreams = await serializer.WriteMessageAsync(stream, message, cancellationToken); | ||
| await WriteEachStreamAsync(serializedStreams, cancellationToken); | ||
|
|
||
| await stream.FlushAsync(cancellationToken); |
rhysparry
approved these changes
Mar 26, 2026
|
|
||
| for (var i = 0; i < clientAndServiceTestCase.RecommendedIterations; i++) | ||
| { | ||
| var result = await echo.SayHelloAsync("hello"); |
Contributor
There was a problem hiding this comment.
With the fix omitted, this fails with "Attempted to read past the end of the stream" (and takes 30-45 seconds to do so for each of the three combinations on my machine).
Not sure if it's worth improving the failure behaviour, but if something obvious can be improved here that could help in the future.
Contributor
Author
There was a problem hiding this comment.
Probably not, its not something we can obviously improve.
| /// A stream that buffers all writes in memory and only forwards them to the underlying | ||
| /// stream when Flush or FlushAsync is called. | ||
| /// </summary> | ||
| public class FlushBufferedStream : DelegateStreamBase |
Contributor
There was a problem hiding this comment.
Is it worth including 'Unbounded' or 'Test' in the name here? I wouldn't want to see this class go wandering outside of tests.
Contributor
Author
There was a problem hiding this comment.
renamed to start with TestOnly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
ref CLOUDPT-11160
ref EFT-3141
Fixes a bug where if the RequestMessage has no data stream, we would not flush it and so we could be in a situation where by both ends are waiting for data to be sent. Since the sender has not flushed the request but is waiting for a response, while the receiver is waiting for the request to be sent.
Shout out to @sahanocto and claude for finding the issue.
Results
Before
Test failed
After
Test passes.
How to review this PR
Quality ✔️
Pre-requisites