Skip to content

TestServer sends remaining content in pipe writer on complete#11268

Closed
JamesNK wants to merge 1 commit into
masterfrom
jamesnk/testserver-pipewriter-flush
Closed

TestServer sends remaining content in pipe writer on complete#11268
JamesNK wants to merge 1 commit into
masterfrom
jamesnk/testserver-pipewriter-flush

Conversation

@JamesNK

@JamesNK JamesNK commented Jun 16, 2019

Copy link
Copy Markdown
Member

Change TestServer to match Kestrel's behavior by sending unflushed content in pipe writer when completing request.

<Compile Update="WebHostService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="WebHostService.cs" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS changed this automatically 🤷‍♂

internal async Task CompleteResponseAsync()
{
// Flush any pending content in writer
await _httpContext.Response.BodyWriter.FlushAsync();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant with PipeWriter.Complete() that's called from CompleteWrites()? Do you just need to reverse the calls to ReturnResponseMessageAsync and CompleteWrites?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'm not sure I understand this change. If the PipeWriter is completed, that should flush any pending content. The reader might see the pending data until after Complete() returns, but that's also true for FlushAsync() with a PauseWriterThreshold of anything other than 1.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't redundant because the unit test fails if FlushAsync isn't here.

Is there a better way to do this?

@analogrelay analogrelay added this to the 3.0.0-preview7 milestone Jun 17, 2019
@Tratcher

Copy link
Copy Markdown
Member

Recommend closing this PR. We realized this is an issue with the PipeWriter polyfill, not with the server. I'll file an issue.

@JamesNK

JamesNK commented Jun 17, 2019

Copy link
Copy Markdown
Member Author

Fix is either #11305 or changing TestServer to use pipes instead of Streams.

@JamesNK JamesNK deleted the jamesnk/testserver-pipewriter-flush branch November 11, 2019 22:51
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-hosting Includes Hosting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants