@@ -495,23 +495,22 @@ export class FirestoreClient {
495
495
}
496
496
497
497
shutdown ( ) : Promise < void > {
498
- if ( this . isShutdown === true ) {
499
- return Promise . resolve ( ) ;
500
- }
501
498
return this . asyncQueue . enqueue ( async ( ) => {
502
- // PORTING NOTE: LocalStore does not need an explicit shutdown on web.
503
- if ( this . lruScheduler ) {
504
- this . lruScheduler . stop ( ) ;
499
+ if ( ! this . isShutdown ) {
500
+ // PORTING NOTE: LocalStore does not need an explicit shutdown on web.
501
+ if ( this . lruScheduler ) {
502
+ this . lruScheduler . stop ( ) ;
503
+ }
504
+ await this . remoteStore . shutdown ( ) ;
505
+ await this . sharedClientState . shutdown ( ) ;
506
+ await this . persistence . shutdown ( ) ;
507
+
508
+ // `removeChangeListener` must be called after shutting down the
509
+ // RemoteStore as it will prevent the RemoteStore from retrieving
510
+ // auth tokens.
511
+ this . credentials . removeChangeListener ( ) ;
512
+ this . isShutdown = true ;
505
513
}
506
- await this . remoteStore . shutdown ( ) ;
507
- await this . sharedClientState . shutdown ( ) ;
508
- await this . persistence . shutdown ( ) ;
509
-
510
- // `removeChangeListener` must be called after shutting down the
511
- // RemoteStore as it will prevent the RemoteStore from retrieving
512
- // auth tokens.
513
- this . credentials . removeChangeListener ( ) ;
514
- this . isShutdown = true ;
515
514
} ) ;
516
515
}
517
516
0 commit comments