-1

I am updating my PouchDB with remote data from CouchDB (couchappy.com). Each time I do it from an empty PouchDB, I get following error:


    ReferenceError {result: Object, stack: (...), message: "writeCheckpoint completed with error"}
    message: "writeCheckpoint completed with error"
    result: Object
    doc_write_failures: 0
    docs_read: 1
    docs_written: 1
    end_time: Fri May 09 2014 02:21:33 GMT+0300 (EEST)
    errors: Array[0]
    last_seq: 36
    ok: false
    start_time: Fri May 09 2014 02:21:32 GMT+0300 (EEST)
    status: "aborted"
    __proto__: Object
    stack: (...)
    get stack: function () { [native code] }
    set stack: function () { [native code] }
    __proto__: Error

Below is my code:


    db.replicate.from('https://(server).couchappy.com/database',{
        live : false,
        doc_ids : flk_content.get('selectedLanguage')
    })
    .on('change',function(){
        console.log(err||response);
    })
    .on('complete',function(){
        db.compact();
    })
    .on('error',function(e){console.log(e);});});   

I get the error message from .on('error') callback.

Once I get the error, if I reload again and data is synchronized again, there is no error.

What means that error? How to prevent it? Is there any further consequence with it? Thanks folks!

EDIT:

More details I get from PouchDB call:


    "ReferenceError: err is not defined
        at Replication. (http://mydomain/myscript:851:508)
        at Replication.EventEmitter.emit (http://mydomain/pouchdb-2.2.0.js:6607:17)
        at http://mydomain/pouchdb-2.2.0.js:5293:19"

Line 851:508 in myscript goes to the replication call I mentioned earlier. I briefly checked pouchDB js and it seems that err is an internal variable used to throw error in


      function finishBatch() {
        writingCheckpoint = true;
        return checkpointer.writeCheckpoint(
          currentBatch.seq
        ).then(function (res) {
          writingCheckpoint = false;
          if (returnValue.cancelled) {
            completeReplication();
            throw new Error('cancelled');
          }
          result.last_seq = last_seq = currentBatch.seq;
          result.docs_written += currentBatch.docs.length;
          returnValue.emit('change', utils.clone(result));
          currentBatch = undefined;
          getChanges();
        })["catch"](function (err) {
          writingCheckpoint = false;
          abortReplication('writeCheckpoint completed with error', err);
          throw err;
        });
      }

So it seems that though error is thrown, err variable is not set?

tup
  • 139
  • 1
  • 8

1 Answers1

1

you never define err (or response) here

.on('change',function(){
    console.log(err||response);
})              ^
Calvin
  • 784
  • 4
  • 10