@@ -199,7 +199,11 @@ export class RemoteStore implements TargetMetadataProvider {
199
199
200
200
private async enableNetworkInternal ( ) : Promise < void > {
201
201
if ( this . canUseNetwork ( ) ) {
202
- this . writeStream . lastStreamToken = await this . localStore . getLastStreamToken ( ) ;
202
+ try {
203
+ this . writeStream . lastStreamToken = await this . localStore . getLastStreamToken ( ) ;
204
+ } catch ( e ) {
205
+ return this . disableNetworkUntilRecovery ( e ) ;
206
+ }
203
207
204
208
if ( this . shouldStartWatchStream ( ) ) {
205
209
this . startWatchStream ( ) ;
@@ -667,7 +671,12 @@ export class RemoteStore implements TargetMetadataProvider {
667
671
this . writeStream . writeMutations ( batch . mutations ) ;
668
672
}
669
673
} )
670
- . catch ( ignoreIfPrimaryLeaseLoss ) ;
674
+ . catch ( ignoreIfPrimaryLeaseLoss )
675
+ . catch ( e =>
676
+ this . disableNetworkUntilRecovery ( e , ( ) =>
677
+ this . localStore . setLastStreamToken ( this . writeStream . lastStreamToken )
678
+ )
679
+ ) ;
671
680
}
672
681
673
682
private async onMutationResult (
@@ -744,7 +753,12 @@ export class RemoteStore implements TargetMetadataProvider {
744
753
745
754
return this . localStore
746
755
. setLastStreamToken ( ByteString . EMPTY_BYTE_STRING )
747
- . catch ( ignoreIfPrimaryLeaseLoss ) ;
756
+ . catch ( ignoreIfPrimaryLeaseLoss )
757
+ . catch ( e =>
758
+ this . disableNetworkUntilRecovery ( e , ( ) =>
759
+ this . localStore . setLastStreamToken ( ByteString . EMPTY_BYTE_STRING )
760
+ )
761
+ ) ;
748
762
} else {
749
763
// Some other error, don't reset stream token. Our stream logic will
750
764
// just retry with exponential backoff.
0 commit comments