@@ -173,7 +173,8 @@ export class ProxyStore {
173
173
http : any ,
174
174
webrtc : any
175
175
} > ( {
176
- adminServerUrl : 'http://127.0.0.1:45456'
176
+ adminServerUrl : 'http://127.0.0.1:45456' ,
177
+ adminStreamReconnectAttempts : Infinity
177
178
} ) ;
178
179
179
180
// These are persisted initially, so we know if the user updates them that we
@@ -237,7 +238,29 @@ export class ProxyStore {
237
238
} ) ;
238
239
} ) ;
239
240
240
- private monitorRemoteClientConnection ( client : PluggableAdmin . AdminClient < { } > ) {
241
+ @observable
242
+ streamDisconnected : boolean = false ;
243
+
244
+ private async monitorRemoteClientConnection ( client : PluggableAdmin . AdminClient < { } > ) {
245
+ // Track stream connect/disconnected state:
246
+ client . on ( 'stream-reconnecting' , action ( ( ) => {
247
+ console . log ( 'Admin client stream reconnecting...' ) ;
248
+ this . streamDisconnected = true ;
249
+ } ) ) ;
250
+
251
+ client . on ( 'stream-reconnected' , action ( ( ) => {
252
+ console . log ( 'Admin client reconnected' ) ;
253
+ this . streamDisconnected = false ;
254
+ } ) ) ;
255
+
256
+ // We show the below as disconnection, but we generally won't recover - this
257
+ // probably means the server has unexpectedly cleanly shut down.
258
+ client . on ( 'stopped' , action ( ( ) => {
259
+ console . log ( 'Server stopped' ) ;
260
+ this . streamDisconnected = true ;
261
+ } ) ) ;
262
+
263
+ // Log various other related events for debugging:
241
264
client . on ( 'stream-error' , ( err ) => {
242
265
console . log ( 'Admin client stream error' , err ) ;
243
266
} ) ;
@@ -246,19 +269,6 @@ export class ProxyStore {
246
269
} ) ;
247
270
client . on ( 'stream-reconnect-failed' , ( err ) => {
248
271
logError ( err . message ? err : new Error ( 'Client reconnect error' ) , { cause : err } ) ;
249
-
250
- alert ( "Server disconnected unexpectedly, app restart required.\n\nPlease report this at github.com/httptoolkit/httptoolkit." ) ;
251
- setTimeout ( ( ) => { // Tiny wait for any other UI events to fire (error reporting/logging/other UI responsiveness)
252
- if ( DesktopApi . restartApp ) {
253
- // Where possible (recent desktop release) we restart the whole app directly
254
- DesktopApi . restartApp ( ) ;
255
- } else if ( ! navigator . platform ?. startsWith ( 'Mac' ) ) {
256
- // If not, on Windows & Linux we just close the window (which restarts)
257
- window . close ( ) ;
258
- }
259
- // On Mac, app exit is independent from window exit, so we can't force that here,
260
- // but hopefully this alert will lead the user to do so themselves.
261
- } , 10 ) ;
262
272
} ) ;
263
273
}
264
274
0 commit comments