@@ -115,34 +115,37 @@ export function VersionDisplay() {
115115 if ( updateLogsData . isComplete ) {
116116 setUpdateLogs ( prev => [ ...prev , 'Update complete! Server restarting...' ] ) ;
117117 setIsNetworkError ( true ) ;
118+ // Start reconnection attempts when we know update is complete
119+ startReconnectAttempts ( ) ;
118120 }
119121 }
120122 } , [ updateLogsData ] ) ;
121123
122- // Monitor for server connection loss and auto-reload
124+ // Monitor for server connection loss and auto-reload (fallback only)
123125 useEffect ( ( ) => {
124126 if ( ! shouldSubscribe ) return ;
125127
126- // Check if logs have stopped coming for a while
128+ // Only use this as a fallback - the main trigger should be completion detection
127129 const checkInterval = setInterval ( ( ) => {
128130 const timeSinceLastLog = Date . now ( ) - lastLogTimeRef . current ;
129131
130- // Only start reconnection if we've been updating for at least 30 seconds
131- // and no logs for 10 seconds (to avoid premature reconnection during npm install )
132- const hasBeenUpdatingLongEnough = updateStartTime && ( Date . now ( ) - updateStartTime ) > 60000 ;
133- const noLogsForAWhile = timeSinceLastLog > 40000 ;
132+ // Only start reconnection if we've been updating for at least 3 minutes
133+ // and no logs for 60 seconds (very conservative fallback )
134+ const hasBeenUpdatingLongEnough = updateStartTime && ( Date . now ( ) - updateStartTime ) > 180000 ; // 3 minutes
135+ const noLogsForAWhile = timeSinceLastLog > 60000 ; // 60 seconds
134136
135- if ( hasBeenUpdatingLongEnough && noLogsForAWhile && isUpdating ) {
137+ if ( hasBeenUpdatingLongEnough && noLogsForAWhile && isUpdating && ! isNetworkError ) {
138+ console . log ( 'Fallback: Assuming server restart due to long silence' ) ;
136139 setIsNetworkError ( true ) ;
137140 setUpdateLogs ( prev => [ ...prev , 'Server restarting... waiting for reconnection...' ] ) ;
138141
139142 // Start trying to reconnect
140143 startReconnectAttempts ( ) ;
141144 }
142- } , 1500 ) ; // Check every 2 seconds instead of 1
145+ } , 10000 ) ; // Check every 10 seconds
143146
144147 return ( ) => clearInterval ( checkInterval ) ;
145- } , [ shouldSubscribe , isUpdating , updateStartTime ] ) ;
148+ } , [ shouldSubscribe , isUpdating , updateStartTime , isNetworkError ] ) ;
146149
147150 // Attempt to reconnect and reload page when server is back
148151 const startReconnectAttempts = ( ) => {
0 commit comments