Cordova PouchDB sync database growing indefinitely

64 views
Skip to first unread message

Paul Gardiner

unread,
Oct 20, 2015, 12:08:28 PM10/20/15
to PouchDB

Hello,

I am using PouchDB to synchronize data between a Cordova app (Android) and a CouchDB instance via a NodeJS proxy. I am not specifying an adapter and the default being used is IndexedDB.  I have got the synchronization working successfully, however the Apps application data (I assume this is the PouchDB database itself) seems to be growing indefinitely. The data is growing each time PouchDB is checking for changes, I know this because I am logging out each request in the proxy and this coincides with the data size increasing.

Any ideas? I must be doing something wrong as I can't believe this is normal as surely it would be pretty unusable.

BTW, I have tried compaction but this seems to have no effect at all. 

Here is a sample of the code I am using:

var headers = {
 ajax
: {
 cache
: false,
 timeout
: 10000,
 headers
: {
 
'x-access-token': localStorageService.get('token')
 
},
 
}
 
};

 
var faamdb = new PouchDB('gr3');
 
var remoteDB = new PouchDB(<URL>, headers);

 
var syncFaamdb = PouchDB.sync(faamdb, remoteDB, {
 live
: true,
 
retry: true,
 back_off_function
: function (delay) {
 
if (delay === 0) {
 
return 1000;
 
}
 
return delay * 3 > 60000 ? 60000 : delay * 3; // At least try every minute
 
}
 
}, {
 ajax
: headers
 
}).on('change', function (info) {
 console
.log('handling change');
 
}).on('paused', function () {
 console
.log('replication paused (e.g. user went off-line)');
 
}).on('active', function () {
 console
.log('replicate resumed (e.g. user went back on-line)');
 
}).on('denied', function (info) {
 console
.log('a document failed to replicate, e.g. due to permissions');
 
}).on('complete', function (info) {
 console
.log('handle complete');
 
}).on('error', function (err) {
 console
.log('handle error');
 
});

Reply all
Reply to author
Forward
0 new messages