@@ -458,40 +458,6 @@ export class LocalStore {
458
458
}
459
459
) ;
460
460
461
- let changedDocKeys = documentKeySet ( ) ;
462
- remoteEvent . documentUpdates . forEach ( ( key , doc ) => {
463
- changedDocKeys = changedDocKeys . add ( key ) ;
464
- promises . push (
465
- documentBuffer . getEntry ( txn , key ) . next ( existingDoc => {
466
- // Make sure we don't apply an old document version to the remote
467
- // cache, though we make an exception for SnapshotVersion.MIN which
468
- // can happen for manufactured events (e.g. in the case of a limbo
469
- // document resolution failing).
470
- if (
471
- existingDoc == null ||
472
- doc . version . isEqual ( SnapshotVersion . MIN ) ||
473
- doc . version . compareTo ( existingDoc . version ) >= 0
474
- ) {
475
- documentBuffer . addEntry ( doc ) ;
476
- } else {
477
- log . debug (
478
- LOG_TAG ,
479
- 'Ignoring outdated watch update for ' ,
480
- key ,
481
- '. Current version:' ,
482
- existingDoc . version ,
483
- ' Watch version:' ,
484
- doc . version
485
- ) ;
486
- }
487
-
488
- // The document might be garbage because it was unreferenced by
489
- // everything. Make sure to mark it as garbage if it is...
490
- this . garbageCollector . addPotentialGarbageKey ( key ) ;
491
- } )
492
- ) ;
493
- } ) ;
494
-
495
461
// HACK: The only reason we allow a null snapshot version is so that we
496
462
// can synthesize remote events when we get permission denied errors while
497
463
// trying to resolve the state of a locally cached document that is in
@@ -502,15 +468,22 @@ export class LocalStore {
502
468
assert (
503
469
remoteVersion . compareTo ( lastRemoteVersion ) >= 0 ,
504
470
'Watch stream reverted to previous snapshot?? ' +
505
- remoteVersion +
506
- ' < ' +
507
- lastRemoteVersion
471
+ remoteVersion +
472
+ ' < ' +
473
+ lastRemoteVersion
508
474
) ;
509
475
promises . push (
510
476
this . queryCache . setLastRemoteSnapshotVersion ( txn , remoteVersion )
511
477
) ;
512
478
}
513
479
480
+ let changedDocKeys = documentKeySet ( ) ;
481
+ remoteEvent . documentUpdates . forEach ( ( key , doc ) => {
482
+ changedDocKeys = changedDocKeys . add ( key ) ;
483
+ documentBuffer . addEntry ( doc ) ;
484
+ this . garbageCollector . addPotentialGarbageKey ( key ) ;
485
+ } ) ;
486
+
514
487
let releasedWriteKeys : DocumentKeySet ;
515
488
return PersistencePromise . waitFor ( promises )
516
489
. next ( ( ) => this . releaseHeldBatchResults ( txn , documentBuffer ) )
0 commit comments