@@ -105,6 +105,7 @@ private static async Task WaitForAngularCliServerToAcceptRequests(Uri cliServerU
105
105
// connection then it's not ready. We keep trying forever because this is dev-mode
106
106
// only, and only a single startup attempt will be made, and there's a further level
107
107
// of timeouts enforced on a per-request basis.
108
+ var timeoutMilliseconds = 1000 ;
108
109
using ( var client = new HttpClient ( ) )
109
110
{
110
111
while ( true )
@@ -114,12 +115,23 @@ private static async Task WaitForAngularCliServerToAcceptRequests(Uri cliServerU
114
115
// If we get any HTTP response, the CLI server is ready
115
116
await client . SendAsync (
116
117
new HttpRequestMessage ( HttpMethod . Head , cliServerUri ) ,
117
- new CancellationTokenSource ( 1000 ) . Token ) ;
118
+ new CancellationTokenSource ( timeoutMilliseconds ) . Token ) ;
118
119
return ;
119
120
}
120
121
catch ( Exception )
121
122
{
122
- await Task . Delay ( 1000 ) ; // 1 second
123
+ await Task . Delay ( 500 ) ;
124
+
125
+ // Depending on the host's networking configuration, the requests can take a while
126
+ // to go through, most likely due to the time spent resolving 'localhost'.
127
+ // Each time we have a failure, allow a bit longer next time (up to a maximum).
128
+ // This only influences the time until we regard the dev server as 'ready', so it
129
+ // doesn't affect the runtime perf (even in dev mode) once the first connection is made.
130
+ // Resolves https://github.com/aspnet/JavaScriptServices/issues/1611
131
+ if ( timeoutMilliseconds < 10000 )
132
+ {
133
+ timeoutMilliseconds += 3000 ;
134
+ }
123
135
}
124
136
}
125
137
}
0 commit comments