Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/pg-cursor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ Cursor.prototype.handleEmptyQuery = function () {
}

Cursor.prototype.handleError = function (msg) {
this.connection.removeListener('noData', this._ifNoData)
this.connection.removeListener('rowDescription', this._rowDescription)
this.state = 'error'
this._error = msg
// satisfy any waiting callback
Expand All @@ -155,8 +153,12 @@ Cursor.prototype.handleError = function (msg) {
// only dispatch error events if we have a listener
this.emit('error', msg)
}
// call sync to keep this connection from hanging
this.connection.sync()
if (this.connection) {
this.connection.removeListener('noData', this._ifNoData)
this.connection.removeListener('rowDescription', this._rowDescription)
// call sync to keep this connection from hanging
this.connection.sync()
}
}

Cursor.prototype._getRows = function (rows, cb) {
Expand Down