seigel/pouchdb-react-native

FYI: there is working alternative already

Opened this issue · 5 comments

For those who stepped in here in searching for updated and actually working RN PDB solution - the guy contributed recently a lot and fixed issues with sync and attachments:
https://dev.to/craftzdog/hacking-pouchdb-to-use-on-react-native-1gjh

The above link is perfect. I ended up coming to almost the exact same conclusion as @craftzdog and have been using PouchDB with RN successfully this way. The only issue I'm encountering is the database not getting fully destroyed by the time db.destroy() resolves, resulting in unpredictability next time you go to create it if it's unknowingly still there.

In addition to his article, you can read more about the performance issues with pouchdb-react-native here: #118

@cjroth How do you deal with .destroy issue?
In my project I'm going to implement destroy as simple way to purge all db docs, are there any issues with creating the same name db after "destroy" old one?

@greenais I haven't really found a good solution yet. I use .destroy when a user logs out, purging all data - similar to you. I've tried generating a random database name each time so that there's never a conflict between old and new data, but even that seems to result in weird, unpredictable behavior (which is extremely weird and worth looking into deeper). I'm thinking a short term fix will be wrapping the destroy method in a promise that just waits for 5-10 seconds and then using something like https://github.com/djhr/react-native-background-execution-ios or https://github.com/ivanzotov/react-native-begin-background-task to ensure that the app has a few extra seconds to finish destroying.

Oddly I had the same issue with the AsyncStorage adapter for pouch too. Maybe it's coincidence or maybe it's a PouchDB-core issue.

@cjroth Did you try to deploy PDB on 64-bit android real device? Unexpectedly (on the edge of release, gosh) I bumped into the fact that in debug mode it works (on device), but once assebled in release apk PDB stops replication with totally uninformative error like:

' !!! PDB _pullDocs ERR: ', { [Error]
  line: 132,
  column: 7285,
  sourceURL: 'index.android.bundle',
  result: 
   { ok: false,
     start_time: '2019-10-19T10:35:28.640Z',
     docs_read: 0,
     docs_written: 0,
     doc_write_failures: 0,
     errors: [],
     status: 'aborting',
     end_time: '2019-10-19T10:35:28.657Z',
     last_seq: 0 } }

The same code on same device, how it could be possible?
32-bit version works with no issues though.
Almost smashed my head in the wall googling, trying, failing..