diff --git a/hooks.js b/hooks.js index c7fbec0..b25850f 100644 --- a/hooks.js +++ b/hooks.js @@ -48,7 +48,7 @@ module.exports = { ? [once(_next), once(_asyncsDone)] : [once(_next)]).concat(hookArgs); return currPre.apply(self, preArgs); - } else if (!proto[name].numAsyncPres) { + } else if (!_asyncsLeft) { return _done.apply(self, hookArgs); } } diff --git a/test.js b/test.js index ef01b88..0f9e69d 100644 --- a/test.js +++ b/test.js @@ -714,5 +714,28 @@ module.exports = { assert.equal(a.value, 7); assert.equal(a.value2, 3); }); + }, + + 'should handle parallel followed by serial': function () { + var A = function () {}; + _.extend(A, hooks); + A.hook('save', function (val, callback) { + this.value = val; + callback(); + }); + A.pre('save', true, function(next, done) { + process.nextTick(function() { + done(); + }); + next(); + }).pre('save', function(done) { + process.nextTick(function() { + done(); + }); + }); + var a = new A(); + a.save(2, function(){ + assert.ok(true); + }); } };