Skip to content

Commit

Permalink
Merge ef8f42d into 0eeb71f
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-hui committed Aug 14, 2019
2 parents 0eeb71f + ef8f42d commit 9bc8480
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/firestore/src/core/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ export class FirestoreClient {
}

unlisten(listener: QueryListener): void {
this.verifyNotShutdown();
// Make unlisten a no-op if client is shut down.
if (this.clientShutdown) {
return;
}
this.asyncQueue.enqueueAndForget(() => {
return this.eventMgr.unlisten(listener);
});
Expand Down
15 changes: 15 additions & 0 deletions packages/firestore/test/integration/api/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,4 +1120,19 @@ apiDescribe('Database', (persistence: boolean) => {
}).to.throw();
});
});

it('can unlisten queries after shutdown', async () => {
return withTestDoc(persistence, async docRef => {
const firestore = docRef.firestore;
const accumulator = new EventsAccumulator<firestore.DocumentSnapshot>();
const unsubscribe = docRef.onSnapshot(accumulator.storeEvent);
await accumulator.awaitEvent();
await shutdownDb(firestore);

// This should proceed without error.
unsubscribe();
// Multiple calls should proceed as well.
unsubscribe();
});
});
});

0 comments on commit 9bc8480

Please sign in to comment.