@@ -236,43 +236,67 @@ Client.prototype._attachListeners = function (con) {
236
236
const self = this
237
237
// delegate rowDescription to active query
238
238
con . on ( 'rowDescription' , function ( msg ) {
239
+ if ( ! self . activeQuery ) {
240
+ return
241
+ }
239
242
self . activeQuery . handleRowDescription ( msg )
240
243
} )
241
244
242
245
// delegate dataRow to active query
243
246
con . on ( 'dataRow' , function ( msg ) {
247
+ if ( ! self . activeQuery ) {
248
+ return
249
+ }
244
250
self . activeQuery . handleDataRow ( msg )
245
251
} )
246
252
247
253
// delegate portalSuspended to active query
248
254
con . on ( 'portalSuspended' , function ( msg ) {
255
+ if ( ! self . activeQuery ) {
256
+ return
257
+ }
249
258
self . activeQuery . handlePortalSuspended ( con )
250
259
} )
251
260
252
261
// deletagate emptyQuery to active query
253
262
con . on ( 'emptyQuery' , function ( msg ) {
263
+ if ( ! self . activeQuery ) {
264
+ return
265
+ }
254
266
self . activeQuery . handleEmptyQuery ( con )
255
267
} )
256
268
257
269
// delegate commandComplete to active query
258
270
con . on ( 'commandComplete' , function ( msg ) {
271
+ if ( ! self . activeQuery ) {
272
+ return
273
+ }
259
274
self . activeQuery . handleCommandComplete ( msg , con )
260
275
} )
261
276
262
277
// if a prepared statement has a name and properly parses
263
278
// we track that its already been executed so we don't parse
264
279
// it again on the same client
265
280
con . on ( 'parseComplete' , function ( msg ) {
281
+ if ( ! self . activeQuery ) {
282
+ return
283
+ }
266
284
if ( self . activeQuery . name ) {
267
285
con . parsedStatements [ self . activeQuery . name ] = true
268
286
}
269
287
} )
270
288
271
289
con . on ( 'copyInResponse' , function ( msg ) {
290
+ if ( ! self . activeQuery ) {
291
+ return
292
+ }
272
293
self . activeQuery . handleCopyInResponse ( self . connection )
273
294
} )
274
295
275
296
con . on ( 'copyData' , function ( msg ) {
297
+ if ( ! self . activeQuery ) {
298
+ return
299
+ }
276
300
self . activeQuery . handleCopyData ( msg , self . connection )
277
301
} )
278
302
0 commit comments