-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
AngularFirestoreCollection sometimes returns duplicate of records after inserting a new record #1728
Comments
the behavior make me confuse too, angularfire 2 actions very weird, I console log it and the data change like this: after add 1 item, it got twice response !!!!!!!!!!
clone repo here |
I am facing a similar issue. Let's say we have a collection with ids: myCollection = ['1', '2', '3', '4', '5'] Correct BehaviorWe do something like that: this.afs.collection('myCollection').snapshotChagnes().subscribe(data => console.log(data)) This gives us:
Everything is fine, just as expected. Unexpected BehaviorHowever, if we do this: this.afs.collection('myCollection').doc('1').valueChanges().subscribe()
this.afs.collection('myCollection').snapshotChagnes().subscribe(data => console.log(data)) This would produce:
Note that I am not printing anything from the ConclusionHaving subscription anywhere to a document that is part of a collection subscription results in collection returning twice. First time an array with just the document we have a subscription to. The second time an array with the entire collection. I don't think this is by design. It makes it very hard to do something like |
I can confirm the behaviors described here. I believe this is a valid bug, and that it is correct to expect that, in this situation, there would be just a single value emitted with the correct query output. So far I have been working around this, although with the negative impact on both user experience and automated testing execution speed, with a short |
#1825 should have dealt with the remaining duplicate issues |
@jamesdaniels I am using |
@jamesdaniels also seeing this issue persist, should we open a new issue? |
Bump, the issue still persists |
Updated the version to "@angular/fire": "^5.2.1", "firebase": "^6.3.3". Issue still there. |
Im still having this problem please help |
any help regarding duplicated items after update? |
Ping!
The issue is still there. |
I find out that the behavior of firestore is like this, first emit is cache data, second emit is true data from server |
the same problem with the latest version of AngularFire and firebase 9 |
Version info
**Angular:**6.0.0
**Firebase:**5.0.4
AngularFire: 5.0.0-rc.10
Other (e.g. Ionic/Cordova, Node, browser, operating system):
How to reproduce these conditions
I have created a firebase app at https://gallery-fb2f9.firebaseapp.com to reproduce the problem . I have not been able to reproduce the problem 100%, but I would say close to 90%. Duplicates are not shown in Firebase's actual database but only appears in the list view that got displayed after a new record has been inserted. If I refresh the screen that shows the duplicates, the correct records are displayed. Please click Titles on the toolbar to display the list.
Failing test unit, Plunkr, or JSFiddle demonstrating the problem
Steps to set up and reproduce
the source codes are at https://github.com/rodkar/angularfirestorecollection
Sample data and security rules
<-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->
Debug output
** Errors in the JavaScript console **
** Output from
firebase.database().enableLogging(true);
**** Screenshots **
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: