@@ -889,6 +889,7 @@ describeSpec('Limbo Documents:', [], () => {
889
889
// to just send the docBs with an existence filter with a count of 3.
890
890
. watchSends ( { affects : [ query1 ] } , docB1 , docB2 , docB3 )
891
891
. watchFilters ( [ query1 ] , [ docB1 . key , docB2 . key , docB3 . key ] )
892
+ . watchCurrents ( query1 , 'resume-token-1001' )
892
893
. watchSnapshots ( 1001 )
893
894
. expectEvents ( query1 , {
894
895
added : [ docB1 , docB2 , docB3 ] ,
@@ -927,6 +928,46 @@ describeSpec('Limbo Documents:', [], () => {
927
928
}
928
929
) ;
929
930
931
+ // Regression test for the bug in https://github.com/firebase/firebase-android-sdk/issues/5357
932
+ specTest (
933
+ 'Limbo resolution should wait for full re-query result if there is an existence filter mismatch ' ,
934
+ [ ] ,
935
+ ( ) => {
936
+ const query1 = query ( 'collection' ) ;
937
+ const docA = doc ( 'collection/a' , 1000 , { v : 1 } ) ;
938
+ const docB = doc ( 'collection/b' , 1000 , { v : 2 } ) ;
939
+ return (
940
+ spec ( )
941
+ . userListens ( query1 )
942
+ . watchAcksFull ( query1 , 1000 , docA , docB )
943
+ . expectEvents ( query1 , { added : [ docA , docB ] } )
944
+ // Simulate that the client loses network connection.
945
+ . disableNetwork ( )
946
+ . expectEvents ( query1 , { fromCache : true } )
947
+ . enableNetwork ( )
948
+ . restoreListen ( query1 , 'resume-token-1000' )
949
+ . watchAcks ( query1 )
950
+ // DocB is deleted in the next sync.
951
+ . watchFilters ( [ query1 ] , [ docA . key ] )
952
+ . watchCurrents ( query1 , 'resume-token-2000' )
953
+ . watchSnapshots ( 2000 )
954
+ . expectActiveTargets ( {
955
+ query : query1 ,
956
+ resumeToken : '' ,
957
+ targetPurpose : TargetPurpose . ExistenceFilterMismatch
958
+ } )
959
+ . watchRemoves ( query1 )
960
+ . watchAcksFull ( query1 , 3000 , docA )
961
+ // Only the deleted doc is moved to limbo after re-query result.
962
+ . expectLimboDocs ( docB . key )
963
+ . ackLimbo ( 3000 , deletedDoc ( docB . key . toString ( ) , 3000 ) )
964
+ . expectLimboDocs ( )
965
+ . expectEvents ( query1 , {
966
+ removed : [ docB ]
967
+ } )
968
+ ) ;
969
+ }
970
+ ) ;
930
971
specTest (
931
972
'Limbo resolution throttling with bloom filter application' ,
932
973
[ ] ,
@@ -968,6 +1009,7 @@ describeSpec('Limbo Documents:', [], () => {
968
1009
[ docB1 . key , docB2 . key , docB3 . key ] ,
969
1010
bloomFilterProto
970
1011
)
1012
+ . watchCurrents ( query1 , 'resume-token-1001' )
971
1013
. watchSnapshots ( 1001 )
972
1014
. expectEvents ( query1 , {
973
1015
added : [ docB1 , docB2 , docB3 ] ,
@@ -978,8 +1020,6 @@ describeSpec('Limbo Documents:', [], () => {
978
1020
// existence filter mismatch. Bloom filter checks membership of the
979
1021
// docs, and filters out docAs, while docBs returns true. Number of
980
1022
// existing docs matches the expected count, so skip the re-query.
981
- . watchCurrents ( query1 , 'resume-token-1002' )
982
- . watchSnapshots ( 1002 )
983
1023
// The docAs are now in limbo; the client begins limbo resolution.
984
1024
. expectLimboDocs ( docA1 . key , docA2 . key )
985
1025
. expectEnqueuedLimboDocs ( docA3 . key )
0 commit comments