我有一个与托管的couchDB很好地同步的pouchDB:
sync.company = db.company.sync(companyUrl, {live: true, retry: true})
在我的应用中,当我检测到网络不再可用时,我停止同步:
if (sync.company) sync.company.cancel();
当网络稍后重新启动时,我的第一步是找出远程主机的最新更新序列:
PouchDB(companyUrl).info().then(function (info) {... <--uncaught error!
但这会引发以下错误:
Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
39.EventEmitter.removeAllListeners
(anonymous function)
39.EventEmitter.emit
39.EventEmitter.removeListener
(anonymous function)
39.EventEmitter.emit
39.EventEmitter.removeListener
39.EventEmitter.removeAllListeners
39.EventEmitter.removeAllListeners
(anonymous function)
OPTIONS <URL>/?_nonce=2isvTJGAXQtX9HWD net::ERR_NETWORK_CHANGED
ajax
ajax
HttpPouch
(anonymous function)
PouchDB
PouchDB
startSync
(anonymous function)
$get.Scope.$digest
$get.Scope.$apply
(anonymous function)
Uncaught (in promise) CustomPouchError
这一切似乎都是从pouchdb.js的第10534行开始的:
if (isFunction(listeners)) {
this.removeListener(type, listeners);
} else {
// LIFO order
while (listeners.length) <------!!!!!!!! error starts here !!!!!
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
这意味着什么?
我正在使用pouchdb 3.2.1
答案 0 :(得分:1)
这是PouchDB中的一个错误,它已在主人中修复。特别是,它由this commit确定。
如果你想生活在最前沿,你可以从源代码构建PouchDB并使用它:
git clone https://github.com/pouchdb/pouchdb && cd pouchdb && npm install && npm run build
或等待下一个版本。 :)