我正在使用CouchDB(couchappy.com)的远程数据更新我的PouchDB。每次我从空的PouchDB中执行此操作时,都会出现以下错误:
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
以下是我的代码:
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);});});
我从.on('error')回调中收到错误消息。
一旦我收到错误,如果我再次重新加载并再次同步数据,则没有错误。
错误是什么意思?怎么预防呢?它有进一步的后果吗? 谢谢大家!
编辑:
我从PouchDB调用得到的更多细节:
"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"
第851行:myscript中的508转到我之前提到的复制调用。 我简要地检查了pouchDB js,似乎err是一个用于在
中抛出错误的内部变量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; }); }
所以似乎虽然抛出了错误,但是没有设置错误变量?
答案 0 :(得分:1)
你永远不会在这里定义错误(或响应)
.on('change',function(){
console.log(err||response);
}) ^