firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.85k stars 893 forks source link

Incorrect sorting behavior, first record always positioned at the end v8.0.2. #4071

Closed heliomarpm closed 3 years ago

heliomarpm commented 3 years ago

Hello, after upgrading from v7.24.0 to v8.0.2, all the compositions are showing incorrect behavior, the first record is always being returned in the last position.

this.fireStore.doc(Users/${this.userId}) .collection<Card>('Cards', ref => ref.where('active', '==', true) .orderBy('order') .orderBy('createdAt', 'desc'));

Example: {order: 1, condition2: 'AA' ...} {order: 2, condition2: 'BB' ...} {order: 3, condition2: 'AB' ...} {order: 4, condition2: 'DD' ...} {order: 3, condition2: 'AB' ...}

Return: {order: 2, condition2: 'BB' ...} {order: 3, condition2: 'AB' ...} {order: 3, condition2: 'AB' ...} {order: 4, condition2: 'DD' ...} {order: 1, condition2: 'AA' ...}

google-oss-bot commented 3 years ago

I found a few problems with this issue:

atsjo commented 3 years ago

Saw similar behavior going from 8.0.1 to 8.0.2, in addition to problems propagating updates in my angular app... Downgrading to 8.0.1 fixes the problem...

heliomarpm commented 3 years ago

Saw similar behavior going from 8.0.1 to 8.0.2, in addition to problems propagating updates in my angular app... Downgrading to 8.0.1 fixes the problem...

I am working with ionic 5 + angular. I also had a propagation problem in version 8.0.2, my solution was to go back to 8.0.0.

wu-hui commented 3 years ago

I believe the issue is from angularfire, filed a issue there: https://github.com/angular/angularfire/issues/2657

jamesdaniels commented 3 years ago

If it is AngularFire it's not 2657. As developers are reporting that they started encountering it with 8.0.2 IMO it's probably the JS SDK.

wu-hui commented 3 years ago

@jamesdaniels Thanks!

@heliomarpm I tried reproduce with angularfire and could not reproduce. Can you kindly provide a mini repro? This would greatly help me identifying the root cause quicker.

schmidt-sebastian commented 3 years ago

This looks like https://github.com/firebase/firebase-js-sdk/issues/4079

@jamesdaniels Does AngularFire use oldIndex or newIndex from DocumentChange?

jamesdaniels commented 3 years ago

@schmidt-sebastian I suspect you're right, AngularFire and RxFire use both old/newIndex: AngularFire combineChange, RxFire processIndividualChange