Skip to content

Commit 91360cc

Browse files
committed
guard for self.activeQuery
1 parent 91a3871 commit 91360cc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/client.js

+24
Original file line numberDiff line numberDiff line change
@@ -236,43 +236,67 @@ Client.prototype._attachListeners = function (con) {
236236
const self = this
237237
// delegate rowDescription to active query
238238
con.on('rowDescription', function (msg) {
239+
if (!self.activeQuery) {
240+
return
241+
}
239242
self.activeQuery.handleRowDescription(msg)
240243
})
241244

242245
// delegate dataRow to active query
243246
con.on('dataRow', function (msg) {
247+
if (!self.activeQuery) {
248+
return
249+
}
244250
self.activeQuery.handleDataRow(msg)
245251
})
246252

247253
// delegate portalSuspended to active query
248254
con.on('portalSuspended', function (msg) {
255+
if (!self.activeQuery) {
256+
return
257+
}
249258
self.activeQuery.handlePortalSuspended(con)
250259
})
251260

252261
// deletagate emptyQuery to active query
253262
con.on('emptyQuery', function (msg) {
263+
if (!self.activeQuery) {
264+
return
265+
}
254266
self.activeQuery.handleEmptyQuery(con)
255267
})
256268

257269
// delegate commandComplete to active query
258270
con.on('commandComplete', function (msg) {
271+
if (!self.activeQuery) {
272+
return
273+
}
259274
self.activeQuery.handleCommandComplete(msg, con)
260275
})
261276

262277
// if a prepared statement has a name and properly parses
263278
// we track that its already been executed so we don't parse
264279
// it again on the same client
265280
con.on('parseComplete', function (msg) {
281+
if (!self.activeQuery) {
282+
return
283+
}
266284
if (self.activeQuery.name) {
267285
con.parsedStatements[self.activeQuery.name] = true
268286
}
269287
})
270288

271289
con.on('copyInResponse', function (msg) {
290+
if (!self.activeQuery) {
291+
return
292+
}
272293
self.activeQuery.handleCopyInResponse(self.connection)
273294
})
274295

275296
con.on('copyData', function (msg) {
297+
if (!self.activeQuery) {
298+
return
299+
}
276300
self.activeQuery.handleCopyData(msg, self.connection)
277301
})
278302

0 commit comments

Comments
 (0)