Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Enforce timeout on network read/writes. #985

Merged
merged 2 commits into from
Apr 30, 2020

Conversation

kasobol-msft
Copy link
Contributor

@kasobol-msft kasobol-msft commented Apr 29, 2020

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

image

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.

@seanmcc-msft
Copy link
Member

Have you ran tests on all 3 platforms (Core 1.3, Core 2.0, and Net Framework)?

@kasobol-msft
Copy link
Contributor Author

Have you ran tests on all 3 platforms (Core 1.3, Core 2.0, and Net Framework)?

@seanmcc-msft I've run tests on all 3 platforms on branch and on master. No regression comparing to master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants