@@ -105,6 +105,7 @@ private static async Task WaitForAngularCliServerToAcceptRequests(Uri cliServerU
105105 // connection then it's not ready. We keep trying forever because this is dev-mode
106106 // only, and only a single startup attempt will be made, and there's a further level
107107 // of timeouts enforced on a per-request basis.
108+ var timeoutMilliseconds = 1000 ;
108109 using ( var client = new HttpClient ( ) )
109110 {
110111 while ( true )
@@ -114,12 +115,23 @@ private static async Task WaitForAngularCliServerToAcceptRequests(Uri cliServerU
114115 // If we get any HTTP response, the CLI server is ready
115116 await client . SendAsync (
116117 new HttpRequestMessage ( HttpMethod . Head , cliServerUri ) ,
117- new CancellationTokenSource ( 1000 ) . Token ) ;
118+ new CancellationTokenSource ( timeoutMilliseconds ) . Token ) ;
118119 return ;
119120 }
120121 catch ( Exception )
121122 {
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+ }
123135 }
124136 }
125137 }
0 commit comments