File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -19,15 +19,19 @@ function Pool(options) {
19
19
20
20
Pool . prototype . getConnection = function ( cb ) {
21
21
if ( this . _closed ) {
22
- return cb ( new Error ( 'Pool is closed.' ) ) ;
22
+ return process . nextTick ( function ( ) {
23
+ return cb ( new Error ( 'Pool is closed.' ) ) ;
24
+ } ) ;
23
25
}
24
26
25
27
var connection ;
26
28
27
29
if ( this . _freeConnections . length > 0 ) {
28
30
connection = this . _freeConnections . shift ( ) ;
29
31
30
- return cb ( null , connection ) ;
32
+ return process . nextTick ( function ( ) {
33
+ return cb ( null , connection ) ;
34
+ } ) ;
31
35
}
32
36
33
37
if ( this . config . connectionLimit === 0 || this . _allConnections . length < this . config . connectionLimit ) {
@@ -49,7 +53,9 @@ Pool.prototype.getConnection = function (cb) {
49
53
}
50
54
51
55
if ( ! this . config . waitForConnections ) {
52
- return cb ( new Error ( 'No connections available.' ) ) ;
56
+ return process . nextTick ( function ( ) {
57
+ return cb ( new Error ( 'No connections available.' ) ) ;
58
+ } ) ;
53
59
}
54
60
55
61
if ( this . config . queueLimit && this . _connectionQueue . length >= this . config . queueLimit ) {
You can’t perform that action at this time.
0 commit comments