Closed eagleoriginal closed 2 years ago
cc @davidfowl
We'll need to repro this and investigate.
I'll investigate
Looks like this is because ReadAtLeastAsync uses the token in BeginOperation
which checks for IsCompleted
which is true as you have a successful WriteAsync before. After that it doesn't use the token again when it waits for more data.
https://github.com/dotnet/runtime/blob/a1f1ab8bc4ad933c36e4dc30172d7dd659ef1012/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/PipeAwaitable.cs#L51
Yep, nice catch @BrennanConroy! We should fix and potentially patch this one.
Description
Infinite wait. OperationCanceledException was not throwed as expected if only part of required length has been readen from stream. In example actually has 12 bytes for read, but syntetical code ReadAtLeastAsync wait for 30 bytes. So it leads to infinite wait ignoring cancelation token.
Reproduction Steps
Expected behavior
Expected getting:
System.OperationCanceledException: The operation was canceled.
Actual behavior
Infinitie wait.....
Known Workarounds
Using this code from Microsoft sources avoid infinite wait:
Configuration
.net 6.0 System.IO.Pipelines v6.0.2