Skip to content

Commit 74ac925

Browse files
authored
[automated] Merge branch 'release/8.0.2xx' => 'release/8.0.3xx' (#39407)
2 parents a723fc2 + e24be20 commit 74ac925

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Containers/Microsoft.NET.Build.Containers/Registry/DefaultRegistryAPI.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ internal class DefaultRegistryAPI : IRegistryAPI
1414
private readonly HttpClient _client;
1515
private readonly ILogger _logger;
1616

17+
// Empirical value - Unoptimized .NET application layers can be ~200MB
18+
// * .NET Runtime (~80MB)
19+
// * ASP.NET Runtime (~25MB)
20+
// * application and dependencies - variable, but _probably_ not more than the BCL?
21+
// Given a 200MB target and a 1Mb/s upload speed, we'd expect an upload speed of 27m:57s.
22+
// Making this a round 30 for convenience.
23+
private static TimeSpan LongRequestTimeout = TimeSpan.FromMinutes(30);
24+
1725
internal DefaultRegistryAPI(string registryName, Uri baseUri, ILogger logger)
1826
{
1927
bool isAmazonECRRegistry = baseUri.IsAmazonECRRegistry();
@@ -33,6 +41,8 @@ private static HttpClient CreateClient(string registryName, Uri baseUri, ILogger
3341
var innerHandler = new SocketsHttpHandler()
3442
{
3543
UseCookies = false,
44+
// the rest of the HTTP stack has an very long timeout (see below) but we should still have a reasonable timeout for the initial connection
45+
ConnectTimeout = TimeSpan.FromSeconds(30)
3646
};
3747

3848
// Ignore certificate for https localhost repository.
@@ -52,7 +62,10 @@ private static HttpClient CreateClient(string registryName, Uri baseUri, ILogger
5262
clientHandler = new AmazonECRMessageHandler(clientHandler);
5363
}
5464

55-
HttpClient client = new(clientHandler);
65+
HttpClient client = new(clientHandler)
66+
{
67+
Timeout = LongRequestTimeout
68+
};
5669

5770
client.DefaultRequestHeaders.Add("User-Agent", $".NET Container Library v{Constants.Version}");
5871

0 commit comments

Comments
 (0)