Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response read timeouts #10128

Merged
merged 16 commits into from
Feb 25, 2020
Merged

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Feb 24, 2020

  1. Adds TryTimeout property to RetryOptions
  2. Disables default HttpClient request timeout
  3. Adds an OperationTimeout policy that handles timeouts inside the pipeline
  4. Adds a wrapper stream that handles timeouts when response if not buffered.

Limitations:

  1. Timeouts for sync reads are not supported
  2. .NET Framework is not consistent in when async reads can be cancelled.

/// <summary>
/// The timeout for a single operation.
/// </summary>
public TimeSpan TryTimeout { get; set; } = TimeSpan.FromSeconds(100);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @KrzysztofCwalina
I took the default HttpClient timeout.

Copy link
Member

Choose a reason for hiding this comment

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

Should this be part of and/or documented in the General Guidelines?

Copy link
Member

Choose a reason for hiding this comment

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

I find the name a little hard to wrap my head around at first glance. PerTryTimeout is kind of awkward but matches the pipeline position naming with PerCall, etc. I don't feel strongly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to NetworkTimeout

}

#if NETCOREAPP
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.NET Framework doesn't react to cancellation token on response reads.

@pakrym pakrym marked this pull request as ready for review February 24, 2020 18:47
@pakrym pakrym requested a review from mikeharder February 24, 2020 21:23
Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

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

This looks really awesome!

/// <summary>
/// The timeout for a single operation.
/// </summary>
public TimeSpan TryTimeout { get; set; } = TimeSpan.FromSeconds(100);
Copy link
Member

Choose a reason for hiding this comment

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

Should this be part of and/or documented in the General Guidelines?

sdk/core/Azure.Core/src/Pipeline/OperationTimeoutPolicy.cs Outdated Show resolved Hide resolved
/// <summary>
/// The timeout for a single operation.
/// </summary>
public TimeSpan TryTimeout { get; set; } = TimeSpan.FromSeconds(100);
Copy link
Member

Choose a reason for hiding this comment

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

I find the name a little hard to wrap my head around at first glance. PerTryTimeout is kind of awkward but matches the pipeline position naming with PerCall, etc. I don't feel strongly here.

@pakrym pakrym merged commit c4c10ac into Azure:master Feb 25, 2020
@pakrym pakrym deleted the pakrym/add-operation-timeout branch February 25, 2020 20:12
@@ -73,7 +73,7 @@ public static HttpPipeline Build(ClientOptions options, HttpPipelinePolicy[] per
diagnostics.LoggedHeaderNames.ToArray(), diagnostics.LoggedQueryParameters.ToArray()));
}

policies.Add(BufferResponsePolicy.Shared);
policies.Add(new ResponseBodyPolicy(options.Retry.NetworkTimeout));
Copy link
Member

Choose a reason for hiding this comment

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

Should we check if the timeout was changed, and if not, use the shared policy

pakrym added a commit that referenced this pull request Feb 26, 2020
AlexanderSher pushed a commit that referenced this pull request Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants