Skip to content

Multiple valueChange subscriptions for same collection leads to one subscription firing changes for another #2740

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

Open
HadiAyoub opened this issue Jan 18, 2021 · 4 comments

Comments

@HadiAyoub
Copy link

Version info

Angular: 10.0.9

Firebase: ^7.13.1

AngularFire: ^6.02

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

Create multiple valueChange subscriptions to the same collection (with a different query)

this.db.collection('/people/' + this.selectedPeopleId + '/messages', ref => ref.orderBy("createdDate").limitToLast(100)).valueChanges({idField: 'documentId'}).subscribe(messageUpdates => 

AND

this.db.collection('/people/' + this.selectedPeopleId + '/messages', ref => ref.where("type", ">", 0).limitToLast(100)).valueChanges({idField: 'documentId'}).subscribe(messageUpdates => 

In my case, I am unsubscribing from the second listener and recreating it with a different limitToLast value (though I'm unsure if that's necessary to reproduce)

Debug output

none

Expected behavior

Each valueChange listener should only fire results for itself

Actual behavior

the first listener is returning valueChanges that match the query for the second listener.

@HadiAyoub
Copy link
Author

HadiAyoub commented Jan 18, 2021

My gut feeling is this could be related to caching?

Can confirm, this is related to query caching. Seems like a bug, rather than intended behaviour as described here though: #2336

as the cached result is incorrect.

@Benny739
Copy link

Benny739 commented Feb 4, 2021

Same issue here.
If you listen to a document directly, it does not even have to be the same collection. If you have multiple listeners and 1 listener gets an update all listeners will fire a "modified" event.

@cm-cm-cm-cm
Copy link

I have noticed this behavior as well

@charliejlevine
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants