Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

domain.dispose() before next(err) #8

Merged
merged 1 commit into from Mar 12, 2013
Jump to file or symbol
Failed to load files and symbols.
+23 −2
Split
View
@@ -8,7 +8,11 @@ module.exports = function () {
reqDomain.dispose();
});
- reqDomain.on('error', next);
+ reqDomain.on('error', function (err) {
+ // Once a domain is disposed, further errors from the emitters in that set will be ignored.
+ reqDomain.dispose();
+ next(err);
+ });
reqDomain.run(next);
};
View
@@ -26,6 +26,15 @@ describe('domain.test.js', function () {
});
return;
}
+ if (req.url === '/async_error_twice') {
+ setTimeout(function () {
+ ff.foo();
+ }, 100);
+ setTimeout(function () {
+ bar.bar();
+ }, 210);
+ return;
+ }
res.end(req.url);
};
@@ -60,9 +69,10 @@ describe('domain.test.js', function () {
before(function () {
mochaHandler = process.listeners('uncaughtException').pop();
});
- after(function () {
+ after(function (done) {
// ...but be sure to re-enable mocha's error handler
process.on('uncaughtException', mochaHandler);
+ setTimeout(done, 500);
});
it('should GET /async_error status 500', function (done) {
@@ -71,6 +81,13 @@ describe('domain.test.js', function () {
.expect('ff is not defined')
.expect(500, done);
});
+
+ it('should GET /async_error_twice status 500', function (done) {
+ request(app)
+ .get('/async_error_twice')
+ .expect('ff is not defined')
+ .expect(500, done);
+ });
});
});