File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ class Connection extends EventEmitter {
96
96
}
97
97
this . packetParser . execute ( data ) ;
98
98
} ) ;
99
+ this . stream . on ( 'end' , ( ) => {
100
+ // emit the end event so that the pooled connection can close the connection
101
+ this . emit ( 'end' ) ;
102
+ } ) ;
99
103
this . stream . on ( 'close' , ( ) => {
100
104
// we need to set this flag everywhere where we want connection to close
101
105
if ( this . _closing ) {
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const { createPool } = require ( '../common.js' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ const pool = createPool ( ) ;
7
+
8
+ pool . getConnection ( ( err , conn ) => {
9
+ assert . ifError ( err ) ;
10
+
11
+ assert ( pool . _allConnections . length === 1 ) ;
12
+ assert ( pool . _freeConnections . length === 0 ) ;
13
+
14
+ // emit the end event, so the connection gets removed from the pool
15
+ conn . stream . emit ( 'end' ) ;
16
+
17
+ assert ( pool . _allConnections . length === 0 ) ;
18
+ assert ( pool . _freeConnections . length === 0 ) ;
19
+
20
+ // As the connection has not really ended we need to do this ourselves
21
+ conn . destroy ( ) ;
22
+ } ) ;
You can’t perform that action at this time.
0 commit comments