diff --git a/.changeset/three-months-lie.md b/.changeset/three-months-lie.md new file mode 100644 index 00000000000..5503fbbd6cf --- /dev/null +++ b/.changeset/three-months-lie.md @@ -0,0 +1,5 @@ +--- +"@firebase/firestore": patch +--- + +Fix a bug that sometimes prevented aggregations from being run when muli-tab persistence was enabled. diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 2d69b322db7..11f05bf4b13 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -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, @@ -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); } diff --git a/packages/firestore/test/integration/api/aggregation.test.ts b/packages/firestore/test/integration/api/aggregation.test.ts index 907934c5cfa..98e2d017875 100644 --- a/packages/firestore/test/integration/api/aggregation.test.ts +++ b/packages/firestore/test/integration/api/aggregation.test.ts @@ -115,7 +115,9 @@ apiDescribe('Count queries', (persistence: boolean) => { }); }); - it('getCountFromServer fails if user is offline', () => { + // TODO(b/277628384): Re-enable this test once b/277628384 is fixed. + // eslint-disable-next-line no-restricted-properties + it.skip('getCountFromServer fails if user is offline', () => { return withEmptyTestCollection(persistence, async (coll, firestore) => { await disableNetwork(firestore); await expect(getCountFromServer(coll)).to.be.eventually.rejectedWith( @@ -293,7 +295,9 @@ apiDescribe('Aggregation queries', (persistence: boolean) => { }); }); - it('getAggregateFromServer fails if user is offline', () => { + // TODO(b/277628384): Re-enable this test once b/277628384 is fixed. + // eslint-disable-next-line no-restricted-properties + it.skip('getAggregateFromServer fails if user is offline', () => { return withEmptyTestCollection(persistence, async (coll, firestore) => { await disableNetwork(firestore); await expect(getCountFromServer(coll)).to.be.eventually.rejectedWith(