Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FYI: there is working alternative already #121

Open
greenais opened this issue Apr 5, 2019 · 5 comments
Open

FYI: there is working alternative already #121

greenais opened this issue Apr 5, 2019 · 5 comments

Comments

@greenais
Copy link

greenais commented Apr 5, 2019

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

@cjroth
Copy link

cjroth commented Apr 25, 2019

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

@greenais
Copy link
Author

@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?

@cjroth
Copy link

cjroth commented Apr 29, 2019

@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.

@greenais
Copy link
Author

@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..

@cjroth
Copy link

cjroth commented Oct 19, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants