Skip to content

Commit 6308f59

Browse files
author
Anton Lakin
committed
patch pool.js to be async consistently
1 parent 515d2de commit 6308f59

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Pool.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ function Pool(options) {
1515

1616
Pool.prototype.getConnection = function (cb) {
1717
if (this._closed) {
18-
return cb(new Error('Pool is closed.'));
18+
process.nextTick(function(){
19+
return cb(new Error('Pool is closed.'));
20+
});
1921
}
2022

2123
var connection;
@@ -46,7 +48,9 @@ Pool.prototype.getConnection = function (cb) {
4648
}
4749

4850
if (!this.config.waitForConnections) {
49-
return cb(new Error('No connections available.'));
51+
process.nextTick(function(){
52+
return cb(new Error('No connections available.'));
53+
});
5054
}
5155

5256
this._connectionQueue.push(cb);

0 commit comments

Comments
 (0)