@@ -824,10 +824,13 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
824824 const labels = this . options . labels ! ;
825825
826826 let needed = reads + writes ;
827+ if ( needed <= 0 ) {
828+ return ;
829+ }
827830 this . _pending += needed ;
828831
829832 // while we can request as many sessions be created as we want, the backend
830- // will return at most 100 at a time. hence the need for a while loop
833+ // will return at most 100 at a time, hence the need for a while loop.
831834 while ( needed > 0 ) {
832835 let sessions : Session [ ] | null = null ;
833836
@@ -862,7 +865,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
862865 *
863866 * @private
864867 *
865- * @fires SessoinPool #error
868+ * @fires SessionPool #error
866869 * @param {Session } session The session to delete.
867870 * @returns {Promise }
868871 */
@@ -909,7 +912,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
909912 */
910913 async _fill ( ) : Promise < void > {
911914 const needed = this . options . min ! - this . size ;
912- if ( ! needed ) {
915+ if ( needed <= 0 ) {
913916 return ;
914917 }
915918
@@ -1046,13 +1049,15 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
10461049 if ( reads + this . size > this . options . max ! ) {
10471050 reads = this . options . max ! - this . size ;
10481051 }
1049- this . _pending += reads ;
1050- promises . push (
1051- new Promise ( ( _ , reject ) => {
1052- this . _pending -= reads ;
1053- this . _createSessions ( { reads, writes : 0 } ) . catch ( reject ) ;
1054- } )
1055- ) ;
1052+ if ( reads > 0 ) {
1053+ this . _pending += reads ;
1054+ promises . push (
1055+ new Promise ( ( _ , reject ) => {
1056+ this . _pending -= reads ;
1057+ this . _createSessions ( { reads, writes : 0 } ) . catch ( reject ) ;
1058+ } )
1059+ ) ;
1060+ }
10561061 }
10571062
10581063 let removeErrorListener : Function ;
0 commit comments