File tree 2 files changed +13
-3
lines changed 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -172,10 +172,10 @@ class Pool extends EventEmitter {
172
172
client . end ( ( ) => {
173
173
this . emit ( 'remove' , client )
174
174
175
- if ( typeof callback === " function" ) {
175
+ if ( typeof callback === ' function' ) {
176
176
callback ( )
177
177
}
178
- } )
178
+ } )
179
179
}
180
180
181
181
connect ( cb ) {
@@ -357,7 +357,7 @@ class Pool extends EventEmitter {
357
357
this . log ( 'remove expended client' )
358
358
}
359
359
360
- return this . _remove ( client , this . _pulseQueue . bind ( this ) )
360
+ return this . _remove ( client , this . _pulseQueue . bind ( this ) )
361
361
}
362
362
363
363
const isExpired = this . _expired . has ( client )
Original file line number Diff line number Diff line change @@ -37,4 +37,14 @@ describe('pool ending', () => {
37
37
expect ( res . rows [ 0 ] . name ) . to . equal ( 'brianc' )
38
38
} )
39
39
)
40
+
41
+ it ( 'pool.end() - finish pending queries' , async ( ) => {
42
+ const pool = new Pool ( { max : 20 } )
43
+ let completed = 0
44
+ for ( let x = 1 ; x <= 20 ; x ++ ) {
45
+ pool . query ( 'SELECT $1::text as name' , [ 'brianc' ] ) . then ( ( ) => completed ++ )
46
+ }
47
+ await pool . end ( )
48
+ expect ( completed ) . to . equal ( 20 )
49
+ } )
40
50
} )
You can’t perform that action at this time.
0 commit comments