@@ -321,6 +321,7 @@ export class IndexedDbPersistence implements Persistence {
321
321
. then ( ( ) => {
322
322
return this . simpleDb . runTransaction (
323
323
'readonly' ,
324
+ /* idempotent= */ false ,
324
325
[ DbTargetGlobal . store ] ,
325
326
txn => {
326
327
return getHighestListenSequenceNumber ( txn ) . next (
@@ -344,8 +345,11 @@ export class IndexedDbPersistence implements Persistence {
344
345
}
345
346
346
347
private startRemoteDocumentCache ( ) : Promise < void > {
347
- return this . simpleDb . runTransaction ( 'readonly' , ALL_STORES , txn =>
348
- this . remoteDocumentCache . start ( txn )
348
+ return this . simpleDb . runTransaction (
349
+ 'readonly' ,
350
+ /* idempotent= */ false ,
351
+ ALL_STORES ,
352
+ txn => this . remoteDocumentCache . start ( txn )
349
353
) ;
350
354
}
351
355
@@ -391,47 +395,52 @@ export class IndexedDbPersistence implements Persistence {
391
395
* primary lease.
392
396
*/
393
397
private updateClientMetadataAndTryBecomePrimary ( ) : Promise < void > {
394
- return this . simpleDb . runTransaction ( 'readwrite' , ALL_STORES , txn => {
395
- const metadataStore = clientMetadataStore ( txn ) ;
396
- return metadataStore
397
- . put (
398
- new DbClientMetadata (
399
- this . clientId ,
400
- Date . now ( ) ,
401
- this . networkEnabled ,
402
- this . inForeground
398
+ return this . simpleDb . runTransaction (
399
+ 'readwrite' ,
400
+ /* idempotent= */ false ,
401
+ ALL_STORES ,
402
+ txn => {
403
+ const metadataStore = clientMetadataStore ( txn ) ;
404
+ return metadataStore
405
+ . put (
406
+ new DbClientMetadata (
407
+ this . clientId ,
408
+ Date . now ( ) ,
409
+ this . networkEnabled ,
410
+ this . inForeground
411
+ )
403
412
)
404
- )
405
- . next ( ( ) => {
406
- if ( this . isPrimary ) {
407
- return this . verifyPrimaryLease ( txn ) . next ( success => {
408
- if ( ! success ) {
409
- this . isPrimary = false ;
410
- this . queue . enqueueAndForget ( ( ) =>
411
- this . primaryStateListener ( false )
412
- ) ;
413
- }
414
- } ) ;
415
- }
416
- } )
417
- . next ( ( ) => this . canActAsPrimary ( txn ) )
418
- . next ( canActAsPrimary => {
419
- const wasPrimary = this . isPrimary ;
420
- this . isPrimary = canActAsPrimary ;
421
-
422
- if ( wasPrimary !== this . isPrimary ) {
423
- this . queue . enqueueAndForget ( ( ) =>
424
- this . primaryStateListener ( this . isPrimary )
425
- ) ;
426
- }
413
+ . next ( ( ) => {
414
+ if ( this . isPrimary ) {
415
+ return this . verifyPrimaryLease ( txn ) . next ( success => {
416
+ if ( ! success ) {
417
+ this . isPrimary = false ;
418
+ this . queue . enqueueAndForget ( ( ) =>
419
+ this . primaryStateListener ( false )
420
+ ) ;
421
+ }
422
+ } ) ;
423
+ }
424
+ } )
425
+ . next ( ( ) => this . canActAsPrimary ( txn ) )
426
+ . next ( canActAsPrimary => {
427
+ const wasPrimary = this . isPrimary ;
428
+ this . isPrimary = canActAsPrimary ;
429
+
430
+ if ( wasPrimary !== this . isPrimary ) {
431
+ this . queue . enqueueAndForget ( ( ) =>
432
+ this . primaryStateListener ( this . isPrimary )
433
+ ) ;
434
+ }
427
435
428
- if ( wasPrimary && ! this . isPrimary ) {
429
- return this . releasePrimaryLeaseIfHeld ( txn ) ;
430
- } else if ( this . isPrimary ) {
431
- return this . acquireOrExtendPrimaryLease ( txn ) ;
432
- }
433
- } ) ;
434
- } ) ;
436
+ if ( wasPrimary && ! this . isPrimary ) {
437
+ return this . releasePrimaryLeaseIfHeld ( txn ) ;
438
+ } else if ( this . isPrimary ) {
439
+ return this . acquireOrExtendPrimaryLease ( txn ) ;
440
+ }
441
+ } ) ;
442
+ }
443
+ ) ;
435
444
}
436
445
437
446
private verifyPrimaryLease (
@@ -646,6 +655,7 @@ export class IndexedDbPersistence implements Persistence {
646
655
this . detachWindowUnloadHook ( ) ;
647
656
await this . simpleDb . runTransaction (
648
657
'readwrite' ,
658
+ /* idempotent= */ false ,
649
659
[ DbPrimaryClient . store , DbClientMetadata . store ] ,
650
660
txn => {
651
661
return this . releasePrimaryLeaseIfHeld ( txn ) . next ( ( ) =>
@@ -678,6 +688,7 @@ export class IndexedDbPersistence implements Persistence {
678
688
getActiveClients ( ) : Promise < ClientId [ ] > {
679
689
return this . simpleDb . runTransaction (
680
690
'readonly' ,
691
+ /* idempotent= */ false ,
681
692
[ DbClientMetadata . store ] ,
682
693
txn => {
683
694
return clientMetadataStore ( txn )
0 commit comments