Skip to content

Commit 9d96d95

Browse files
Don't raise hasPendingWrites for documents outside of limit (#1178)
1 parent 00b50e1 commit 9d96d95

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/firestore/src/core/view.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export class View {
207207
while (newDocumentSet.size > this.query.limit!) {
208208
const oldDoc = newDocumentSet.last();
209209
newDocumentSet = newDocumentSet.delete(oldDoc!.key);
210+
newMutatedKeys = newMutatedKeys.delete(oldDoc!.key);
210211
changeSet.track({ type: ChangeType.Removed, doc: oldDoc! });
211212
}
212213
}

packages/firestore/test/unit/specs/limit_spec.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ describeSpec('Limits:', [], () => {
4141
});
4242
});
4343

44+
specTest(
45+
"Documents outside of limit don't raise hasPendingWrites",
46+
[],
47+
() => {
48+
const query1 = Query.atPath(path('collection')).withLimit(2);
49+
const doc1 = doc('collection/a', 1000, { key: 'a' });
50+
const doc2 = doc('collection/b', 1000, { key: 'b' });
51+
52+
return spec()
53+
.withGCEnabled(false)
54+
.userListens(query1)
55+
.watchAcksFull(query1, 1000, doc1, doc2)
56+
.expectEvents(query1, {
57+
added: [doc1, doc2]
58+
})
59+
.userUnlistens(query1)
60+
.userSets('collection/c', { key: 'c' })
61+
.userListens(query1, 'resume-token-1000')
62+
.expectEvents(query1, {
63+
added: [doc1, doc2],
64+
fromCache: true
65+
});
66+
}
67+
);
68+
4469
specTest('Deleted Document in limbo in full limit query', [], () => {
4570
const query = Query.atPath(path('collection')).withLimit(2);
4671
const doc1 = doc('collection/a', 1000, { key: 'a' });

0 commit comments

Comments
 (0)