File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 7373if ( app . Environment . IsDevelopment ( ) )
7474{
7575 // Start the Angular dev server if it's not running
76- var portAvailable = System . Net . NetworkInformation . IPGlobalProperties . GetIPGlobalProperties ( )
77- . GetActiveTcpListeners ( ) . All ( x => x . Port != 4200 ) ;
78- if ( portAvailable && nodeProxy . TryStartNode ( "../MyApp.Client" , out var process ) )
76+ bool IsPortAvailable ( int port ) => System . Net . NetworkInformation . IPGlobalProperties . GetIPGlobalProperties ( )
77+ . GetActiveTcpListeners ( ) . All ( x => x . Port != port ) ;
78+ if ( IsPortAvailable ( 4200 ) && nodeProxy . TryStartNode ( "../MyApp.Client" , out var process ) )
7979 {
8080 app . Lifetime . ApplicationStopping . Register ( ( ) => {
8181 if ( ! process . HasExited )
8989 app . UseWebSockets ( ) ;
9090 app . MapViteHmr ( nodeProxy ) ;
9191 app . MapFallbackToNode ( nodeProxy ) ;
92- Thread . Sleep ( 200 ) ; // Wait for Node to start
92+
93+ // Wait for Angular dev server to start
94+ var timeout = TimeSpan . FromSeconds ( 30 ) ;
95+ var started = DateTime . UtcNow ;
96+ while ( DateTime . UtcNow - started < timeout )
97+ {
98+ if ( IsPortAvailable ( 4200 ) )
99+ break ;
100+ Thread . Sleep ( 100 ) ;
101+ }
93102}
94103else
95104{
You can’t perform that action at this time.
0 commit comments