Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix bug of infinite wait when create object aync error

  • Loading branch information...
commit 5e1455f517e26a5b85a00307f9341854a07156f2 1 parent 69180f3
windyrobin windyrobin authored
Showing with 29 additions and 0 deletions.
  1. +1 −0  lib/generic-pool.js
  2. +28 −0 test/generic-pool.test.js
1  lib/generic-pool.js
View
@@ -255,6 +255,7 @@ exports.Pool = function (factory) {
}
if (err) {
count -= 1;
+ dispense();
clientCb(err, obj);
} else {
if (clientCb) {
28 test/generic-pool.test.js
View
@@ -511,6 +511,34 @@ module.exports = {
});
assert.equal(destroyCalled, true);
assert.equal(pool.availableObjectsCount(), 0);
+ },
+
+ 'do schedule again if error occured when creating new Objects async': function(beforeExit){
+ var factory = {
+ name: 'test',
+ create: function(callback) {
+ process.nextTick(function(){
+ var err = new Error('Create Error');
+ callback(err);
+ })
+ },
+ destroy: function(client) {},
+ max: 1,
+ idleTimeoutMillis: 100
+ };
+
+ var getFlag = 0;
+ var pool = poolModule.Pool(factory);
+ pool.acquire(function(){});
+ pool.acquire(function(err, obj){
+ getFlag = 1;
+ assert(err);
+ assert.equal(pool.availableObjectsCount(), 0);
+ });
+
+ beforeExit(function() {
+ assert.equal(getFlag, 1);
+ });
}
Please sign in to comment.
Something went wrong with that request. Please try again.