From 85c28e9088f4a00e9bf5a61c7ebf516ce08af2a4 Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Thu, 17 Apr 2014 16:25:59 +0800 Subject: [PATCH] destroyAllNow also has a callback --- lib/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 02c01636..5a395ede 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,11 +25,12 @@ PG.prototype.end = function() { var pool = self.pools.all[key]; delete self.pools.all[key]; pool.drain(function() { - pool.destroyAllNow(); - count--; - if(count === 0) { - self.emit('ended'); - } + pool.destroyAllNow(function() { + count--; + if(count === 0) { + self.emit('ended'); + } + }); }); }); };