You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the newest version and if i use collectionData(query(ref)) it fires once so this is correct.
If I am using collectionData(query(ref, ...whereStatements) and with one where statement it fires twice to the subscribe method returns twice.
Reacted by mlahp7, Maxime Carrière, Daniel Wildegger, Narongdej Sarnsuwan, Flavien Normand, Benj Hingston and vhanded
Hey @benzmarkus and @mvgijssel! Thanks for the report! Can one of you create a small sample in StackBlitz, a small GitHub repo, or something of the like? I'd be happy to debug.
We are experiencing this issue as well.
It doesn't happen every time collectionData is called, but on subsequent calls. The first chunk of data is only a subset of the result we are expecting, the second chunk that comes through is the full result we expect.
Reacted by Maxime Carrière, Benj Hingston and vhanded
@davideast As @ronnelreposo mentioned it can be reproduced with the snippet in the example use from the readme. Do you need more information to be able to reproduce the issue?
I have a (ugly but working) workaround for the time being. For me the first time I subscribed to the query it behaved correctly, but afterwards the problem @benzmarkus describes occurred.
In my case the query is called within an effect from a component store. Inside the store I have a variable called firstSubscription, that tracks if its the first subscription or not (Captain Obvious right there).
If that variable is false, I skip the first emission from collectionData:
Any news on that? It's quite impactful when some other operations depend on that and thus fire twice themselves, throttleTime and other operators being just hotfixes that don't really fix the main issue.
This is likely related to the includeMetadataChanges option being hard coded to true when setting up the onSnapshot, which will always trigger the snapshot callback twice after writes (as this is the behaviour of the underlying Firebase library – it performs optimistic updates client-side, and then updates the hasPendingWrites metadata flag after the server-side update is confirmed).
Activity
mvgijssel commentedon Feb 10, 2022
I'm experiencing the exact same issue using rxfire
6.0.3also with a collectionData and a where condition.davideast commentedon Feb 13, 2022
Hey @benzmarkus and @mvgijssel! Thanks for the report! Can one of you create a small sample in StackBlitz, a small GitHub repo, or something of the like? I'd be happy to debug.
ronnelreposo commentedon Feb 19, 2022
The same experience @davideast, I tried the code snipper in example-use, without
wherestatement.mlahp7 commentedon Mar 9, 2022
We are experiencing this issue as well.
It doesn't happen every time collectionData is called, but on subsequent calls. The first chunk of data is only a subset of the result we are expecting, the second chunk that comes through is the full result we expect.
masterodi commentedon Mar 15, 2022
Did anyone find a solution or workaround for this?
SpraylnlPray commentedon Jun 5, 2022
@davideast As @ronnelreposo mentioned it can be reproduced with the snippet in the example use from the readme. Do you need more information to be able to reproduce the issue?
SpraylnlPray commentedon Jun 5, 2022
I have a (ugly but working) workaround for the time being. For me the first time I subscribed to the query it behaved correctly, but afterwards the problem @benzmarkus describes occurred.
In my case the query is called within an effect from a component store. Inside the store I have a variable called
firstSubscription, that tracks if its the first subscription or not (Captain Obvious right there).If that variable is
false, I skip the first emission fromcollectionData:Hope this helps someone
narongdejsrn commentedon Jul 10, 2022
Another workaround that I found is to use throttleTime
For example
markklesel commentedon Aug 31, 2022
@dependabot reopen
Supamiu commentedon Oct 20, 2022
Any news on that? It's quite impactful when some other operations depend on that and thus fire twice themselves, throttleTime and other operators being just hotfixes that don't really fix the main issue.
jits commentedon Aug 15, 2023
This is likely related to the
includeMetadataChangesoption being hard coded totruewhen setting up theonSnapshot, which will always trigger the snapshot callback twice after writes (as this is the behaviour of the underlying Firebase library – it performs optimistic updates client-side, and then updates thehasPendingWritesmetadata flag after the server-side update is confirmed).