fix: only dispatch error events if we have a listener

This commit is contained in:
Sam Beran 2017-05-09 09:16:45 -05:00
parent acae15de53
commit 2f480217cb

View File

@ -115,7 +115,11 @@ Cursor.prototype.handleError = function(msg) {
for(var i = 0; i < this._queue.length; i++) {
this._queue.pop()[1](msg)
}
this.emit('error', msg)
if (this.eventNames().indexOf('error') >= 0) {
//only dispatch error events if we have a listener
this.emit('error', msg)
}
//call sync to keep this connection from hanging
this.connection.sync()
}