seigel / pouchdb-react-native

Pouchdb with async storage
MIT License
484 stars 68 forks source link

Local database hangs after large syncs (no writedb in Transform class) #16

Closed nlieb closed 8 years ago

nlieb commented 8 years ago

When syncing from a remote database to a local one, after two batches (defaults to 100 documents, can use options.batch_size in PouchDB.sync() to change) the local database will hang with the following warning appearing:

Possible Unhandled Promise Rejection (id: 0): no writecb in Transform class

The stack trace of the promise rejection is not very useful so beyond that I'm at a loss. Curiously, you can change batch_size to 1000+ and get more documents through before it fails.

I've created a minimal test case here: https://github.com/nwlieb/pouch-react-test. This is tested on MacOS with iOS, Windows with android, using both couchdb and pouchdb-server remotes. It has also been tested with live replication and by sequential non-live syncs.

stockulus commented 8 years ago

Hi,

just did git clone https://github.com/nwlieb/pouch-react-test cd pouch-react-test npm install node ./node_modules/react-native/local-cli/cli.js run-ios (CouchDb running in a Docker Container, local, klaemo/couchdb) (node v6.3.0)

screen shot 2016-07-22 at 12 21 48 demo app

it keeps on Syncing...

Do i miss something?

Greez Christoph

nlieb commented 8 years ago

Hi, please try increasing the remote docs insert count to 2000 from 300, that should do it (updated the test repo if you want to pull the change). Otherwise, just keep reloading the app and you should see it eventually. screen shot 2016-07-22 at 11 59 32 am

Thanks for your great work.

stockulus commented 8 years ago

Hi, I can now reproduce the Error, comes from https://github.com/nodejs/readable-stream, just do not know why.

I am currently planning to rewrite the adapter, without all the leveldown simulation; this should solve the issue

abelcha commented 8 years ago

Hi @stockulus, Same problem here, when do you think it'll be fixed ?

stockulus commented 8 years ago

I have to finish a Project this Week, hope i get some time next week. You could help me with working Testsetup if you want / seen some react-native-mock, already used it in an other Project.

abelcha commented 8 years ago

I'll be glad to participate on the project, So if i understood correctly, i should create a test-case app with react-native-mock ?

stockulus commented 8 years ago

already got help with the test setup, I let you know shortly when i need some help with testing the new version

abelcha commented 8 years ago

Ok perfect then, let me know if you need a hand

ck-kc commented 8 years ago

Just to confirm that I am also seeing the error on occasion. Am using pouchdb-react-native with Cloudant and pouchdb-authentication-cloudant. Not exactly sure how to reproduce in my setup. I am replicating a local database to a remote one like the following:

var replicator = PouchDB.replicate(db, remotedb, { live: true, retry: true });

ewnd9 commented 8 years ago

@ck-alpha What version of pouchdb-react-native do you use?

ck-kc commented 8 years ago

It is 5.4.6 @ewnd9

stockulus commented 8 years ago

should be fixed in the latest version, but see issue https://github.com/stockulus/pouchdb-react-native/issues/27