apache / apache/pouchdb

In case of conflict (because of revs_limit reached), PouchDb gives us outdated revision in sync/change callback

Open
#8,654 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue
After being offline for a while, in case of conflict (because of revs_limit reached), PouchDb gives us in change callback an outdated revision.

### Info
- Environment: Electron App 21.4.2 / Vue.js 3 / PouchDB 8.0.1
- Platform: Electron/Chromium
- Adapter: indexeddb
- Server: CouchDB

### Reproduce

1. You start livesync on a database.
2. You go offline.
3. You modify a single doc a number of times upper than the revs_limit defined.
4. You go back online
5. PouchDB syncs (push) the modified docs to the CouchDB server
6. This results in a conflict (the winner is determined by the server, always choosing the last revision)
7. PouchDB is notified of changes (pull) (conflict résolution)
8. PouchDB made 3 pull with the same changes and calls our 'change' callback but gives us each time the same revision : the one that is declared as conflicting.
9. If in this change callback, we make a `db.get(docId)`, this correctly returns the right revision (the last) (So the data in the local database are good)

To avoid this behaviour, we increased the revs_limit, but I supposed there is a better way ;)

Regards
Manuel

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.