@@ -174,9 +174,22 @@ function createPool(poolAttrs, createPoolCb) {
174
174
// be called by the database when a connection acquired from the pool doesn't
175
175
// have the requested tag
176
176
sessionCallback = poolAttrs . sessionCallback ;
177
+
178
+ // create an adjusted set of pool attributes to pass to the C layer; the
179
+ // session callback must be removed if it is a JavaScript function and the
180
+ // queue timeout is used to specify the maximum amount of time that the C
181
+ // layer will wait for a connection to be returned; ordinarily since the
182
+ // JavaScript layer never calls the C layer to get a connection unless one is
183
+ // known to be available, this should not be needed, but in some cases (such
184
+ // as when the maximum for a particular shard is specified) this may not be
185
+ // known, so this prevents an unnecessarily long wait from taking place
186
+ const adjustedPoolAttrs = Object . defineProperties ( { } ,
187
+ Object . getOwnPropertyDescriptors ( poolAttrs ) ) ;
177
188
if ( typeof poolAttrs . sessionCallback === 'function' ) {
178
- poolAttrs = Object . assign ( { } , poolAttrs ) ;
179
- delete poolAttrs . sessionCallback ;
189
+ delete adjustedPoolAttrs . sessionCallback ;
190
+ }
191
+ if ( adjustedPoolAttrs . queueTimeout === undefined ) {
192
+ adjustedPoolAttrs . queueTimeout = self . queueTimeout ;
180
193
}
181
194
182
195
// Need to prevent another call in the same stack from succeeding, otherwise
@@ -186,7 +199,7 @@ function createPool(poolAttrs, createPoolCb) {
186
199
tempUsedPoolAliases [ poolAlias ] = true ;
187
200
}
188
201
189
- self . _createPool ( poolAttrs , function ( err , poolInst ) {
202
+ self . _createPool ( adjustedPoolAttrs , function ( err , poolInst ) {
190
203
if ( err ) {
191
204
// We need to free this up since the creation of the pool failed.
192
205
if ( poolAlias ) {
@@ -208,7 +221,6 @@ function createPool(poolAttrs, createPoolCb) {
208
221
delete tempUsedPoolAliases [ poolAlias ] ;
209
222
}
210
223
211
- poolAttrs . sessionCallback = sessionCallback ;
212
224
poolInst . _setup ( poolAttrs , poolAlias , self ) ;
213
225
214
226
poolInst . on ( '_after_close' , function ( ) {
0 commit comments