diff --git a/lib/client.js b/lib/client.js index 147637ee7..106e77593 100644 --- a/lib/client.js +++ b/lib/client.js @@ -283,29 +283,39 @@ Client.prototype._attachListeners = function (con) { const self = this // delegate rowDescription to active query con.on('rowDescription', function (msg) { - self.activeQuery.handleRowDescription(msg) + if (self.activeQuery) { + self.activeQuery.handleRowDescription(msg) + } }) // delegate dataRow to active query con.on('dataRow', function (msg) { - self.activeQuery.handleDataRow(msg) + if (self.activeQuery) { + self.activeQuery.handleDataRow(msg) + } }) // delegate portalSuspended to active query // eslint-disable-next-line no-unused-vars con.on('portalSuspended', function (msg) { - self.activeQuery.handlePortalSuspended(con) + if (self.activeQuery) { + self.activeQuery.handlePortalSuspended(con) + } }) // delegate emptyQuery to active query // eslint-disable-next-line no-unused-vars con.on('emptyQuery', function (msg) { - self.activeQuery.handleEmptyQuery(con) + if (self.activeQuery) { + self.activeQuery.handleEmptyQuery(con) + } }) // delegate commandComplete to active query con.on('commandComplete', function (msg) { - self.activeQuery.handleCommandComplete(msg, con) + if (self.activeQuery) { + self.activeQuery.handleCommandComplete(msg, con) + } }) // if a prepared statement has a name and properly parses @@ -313,11 +323,12 @@ Client.prototype._attachListeners = function (con) { // it again on the same client // eslint-disable-next-line no-unused-vars con.on('parseComplete', function (msg) { - if (self.activeQuery.name) { + if (self.activeQuery && self.activeQuery.name) { con.parsedStatements[self.activeQuery.name] = self.activeQuery.text } }) + // eslint-disable-next-line no-unused-vars con.on('copyInResponse', function (msg) { self.activeQuery.handleCopyInResponse(self.connection) diff --git a/package.json b/package.json index c7b3ce039..e07618fbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pg", - "version": "7.11.0", + "version": "7.11.1", "description": "PostgreSQL client - pure javascript & libpq with the same API", "keywords": [ "database", @@ -27,6 +27,9 @@ "pgpass": "1.x", "semver": "4.3.2" }, + "publishConfig": { + "registry": "http://admin.branch.io:8081/nexus/content/repositories/npm-internal/" + }, "devDependencies": { "async": "0.9.0", "bluebird": "3.5.2",