Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed calling next() 2x after throwing

  • Loading branch information...
commit d2027b7e5dc30448dc9093601f86d14244ddb17a 1 parent 1e9d8ec
@aheckmann authored
Showing with 11 additions and 7 deletions.
  1. +1 −1  hooks.js
  2. +10 −6 test.js
View
2  hooks.js
@@ -155,7 +155,7 @@ module.exports = {
function once (fn, scope) {
return function fnWrapper () {
if (fnWrapper.hookCalled) return;
- fn.apply(scope, arguments);
fnWrapper.hookCalled = true;
+ fn.apply(scope, arguments);
};
}
View
16 test.js
@@ -525,7 +525,7 @@ module.exports = {
}, 1000);
},
- 'calling the same next multiple times should have the effect of only calling it once': function () {
+ 'calling the same next multiple times should have the effect of only calling it once': function (beforeExit) {
var A = function () {
this.acked = false;
};
@@ -535,17 +535,21 @@ module.exports = {
this.acked = true;
});
A.pre('ack', function (next) {
- next();
- next();
+ // force a throw to re-exec next()
+ try {
+ next(new Error('bam'));
+ } catch (err) {
+ next();
+ }
});
A.pre('ack', function (next) {
- // Notice that next() is not invoked here
+ next();
});
var a = new A();
a.ack();
- setTimeout( function () {
+ beforeExit( function () {
a.acked.should.be.false;
- }, 1000);
+ });
},
'asynchronous middleware should be able to pass an error via `done`, stopping the middleware chain': function () {
Please sign in to comment.
Something went wrong with that request. Please try again.