This repository was archived by the owner on Aug 1, 2024. It is now read-only.
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.
Problem
This is to address situation when response parsing hangs on reading response stream indefinitely here https://github.com/dotnet/runtime/blob/5d5c36bb9e887cfe50913840ba96985da113640f/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs#L1195 .
The reproduction scenario : https://gist.github.com/brettsam/85950a65fc50da044dee6ec242944895
Solution
The solution is inspired by V12 where timeouts are enforced by wrapping response stream ReadTimeoutStream .
Additionally
ByteCountingStream
wrapper has been fixed - absent override were causing it to use default implementation - effectively loosing cancellation token and not passing it into http/network stack.Extra
Additionally
WithCancellation
extension has been improved to mark exceptions thrown by abandoned tasks as handled.Testing
I've been running reproduction scenario and observed that after changes it didn't hang but threw cancellation exception.