File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -372,8 +372,10 @@ class Pool extends EventEmitter {
372
372
let tid
373
373
if ( this . options . idleTimeoutMillis && this . _isAboveMin ( ) ) {
374
374
tid = setTimeout ( ( ) => {
375
- this . log ( 'remove idle client' )
376
- this . _remove ( client , this . _pulseQueue . bind ( this ) )
375
+ if ( this . _isAboveMin ( ) ) {
376
+ this . log ( 'remove idle client' )
377
+ this . _remove ( client , this . _pulseQueue . bind ( this ) )
378
+ }
377
379
} , this . options . idleTimeoutMillis )
378
380
379
381
if ( this . options . allowExitOnIdle ) {
Original file line number Diff line number Diff line change @@ -124,3 +124,19 @@ describe('pool size of 2', () => {
124
124
} )
125
125
)
126
126
} )
127
+
128
+ describe ( 'pool min size' , ( ) => {
129
+ it (
130
+ 'does not drop below min when clients released at same time' ,
131
+ co . wrap ( function * ( ) {
132
+ const pool = new Pool ( { max : 2 , min : 1 , idleTimeoutMillis : 10 } )
133
+ const client = yield pool . connect ( )
134
+ const client2 = yield pool . connect ( )
135
+ client . release ( )
136
+ client2 . release ( )
137
+ yield new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) )
138
+ expect ( pool . idleCount ) . to . equal ( 1 )
139
+ return yield pool . end ( )
140
+ } )
141
+ )
142
+ } )
You can’t perform that action at this time.
0 commit comments