Skip to content

Allow aggregations to work with multi-tab. #7212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/three-months-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
---

Fix a bug that prevented aggregations from being run when muli-tab was enabled.
20 changes: 5 additions & 15 deletions packages/firestore/src/core/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { newSerializer } from '../platform/serializer';
import { newTextEncoder } from '../platform/text_serializer';
import { Datastore, invokeRunAggregationQueryRpc } from '../remote/datastore';
import {
canUseNetwork,
RemoteStore,
remoteStoreDisableNetwork,
remoteStoreEnableNetwork,
Expand Down Expand Up @@ -536,20 +535,11 @@ export function firestoreClientRunAggregateQuery(
// to the implementation in firestoreClientGetDocumentsViaSnapshotListener
// above
try {
const remoteStore = await getRemoteStore(client);
if (!canUseNetwork(remoteStore)) {
deferred.reject(
new FirestoreError(
Code.UNAVAILABLE,
'Failed to get aggregate result because the client is offline.'
)
);
} else {
const datastore = await getDatastore(client);
deferred.resolve(
invokeRunAggregationQueryRpc(datastore, query, aggregates)
);
}
// TODO(b/277628384): check `canUseNetwork()` and handle multi-tab.
const datastore = await getDatastore(client);
deferred.resolve(
invokeRunAggregationQueryRpc(datastore, query, aggregates)
);
} catch (e) {
deferred.reject(e as Error);
}
Expand Down