mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
In Angular CLI middleware, remove additional level of timeouts since it's now covered upstream. Part of #1447
This commit is contained in:
@@ -102,13 +102,11 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
|||||||
{
|
{
|
||||||
// To determine when it's actually ready, try making HEAD requests to '/'. If it
|
// To determine when it's actually ready, try making HEAD requests to '/'. If it
|
||||||
// produces any HTTP response (even if it's 404) then it's ready. If it rejects the
|
// produces any HTTP response (even if it's 404) then it's ready. If it rejects the
|
||||||
// connection then it's not ready.
|
// connection then it's not ready. We keep trying forever because this is dev-mode
|
||||||
const int MaxAttempts = 10;
|
// only, and only a single startup attempt will be made, and there's a further level
|
||||||
const int SecondsBetweenAttempts = 1;
|
// of timeouts enforced on a per-request basis.
|
||||||
|
using (var client = new HttpClient())
|
||||||
var attemptsMade = 0;
|
{
|
||||||
var client = new HttpClient();
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -119,17 +117,10 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
|||||||
new CancellationTokenSource(1000).Token);
|
new CancellationTokenSource(1000).Token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
attemptsMade++;
|
await Task.Delay(1000); // 1 second
|
||||||
if (attemptsMade >= MaxAttempts)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(
|
|
||||||
"Timed out waiting for the @angular/cli server to accept HTTP requests. " +
|
|
||||||
"See inner exception for details.", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(SecondsBetweenAttempts * 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user