cozy-labs / cozy-desktop

File Synchronisation for Cozy on Desktop and Laptop
https://cozy-labs.github.io/cozy-desktop/
GNU Affero General Public License v3.0
98 stars 45 forks source link

fix: Prevent race conditions between in Sync #2323

Closed taratatach closed 9 months ago

taratatach commented 9 months ago

The PouchDB changes observers in Sync could cancel each other while events would still be emitted but those emitted for waitForNewChanges would not get returned to the caller because this.changes would be null at that point.

We would then stop synchronizing changes!

Separating the changes observers using local variables should fix this.

Please make sure the following boxes are checked: