File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -410,8 +410,9 @@ class StaticServer {
410
410
}
411
411
412
412
async _handleAppStateChange ( appState : AppStateStatus ) {
413
+ const starting = appState === 'active' ;
413
414
try {
414
- if ( appState === 'active' ) await this . start ( 'App entered foreground' ) ;
415
+ if ( starting ) await this . start ( 'App entered foreground' ) ;
415
416
else await this . _stop ( 'App entered background' ) ;
416
417
} catch ( e ) {
417
418
// If anything goes wrong within .start() or ._stop() calls, those methods
@@ -425,12 +426,18 @@ class StaticServer {
425
426
// it as unhandled, which is confusing when the error has been handled
426
427
// within the listener).
427
428
//
428
- // However, if no listeners are connected, we re- throw the error to allow
429
+ // However, if no listeners are connected, we throw an error to allow
429
430
// the instrumentation, if any, to detect and report it as unhandled.
430
431
//
431
432
// In either case this very function is used internally, thus no way for
432
433
// the library consumer to directly handle its possible rejections.
433
- if ( ! this . _stateChangeEmitter . hasListeners ) throw e ;
434
+ if ( ! this . _stateChangeEmitter . hasListeners ) {
435
+ throw Error (
436
+ starting
437
+ ? 'Server auto-start on the app going into foreground failed'
438
+ : 'Server auto-stop on the app going into background failed' ,
439
+ ) ;
440
+ }
434
441
}
435
442
}
436
443
}
You can’t perform that action at this time.
0 commit comments