Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fixed runner emitter leak. closes #432

TJ Holowaychuk1c2b0673f259
diff --git a/lib/runner.js b/lib/runner.js
index 09a646fb..d60a97f7 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -436,10 +436,15 @@ Runner.prototype.run = function(fn){
debug('start');
+ // uncaught callback
+ function uncaught(err) {
+ self.uncaught(err);
+ }
+
// callback
this.on('end', function(){
debug('end');
- process.removeListener('uncaughtException', this.uncaught);
+ process.removeListener('uncaughtException', uncaught);
fn(self.failures);
});
@@ -451,9 +456,7 @@ Runner.prototype.run = function(fn){
});
// uncaught exception
- process.on('uncaughtException', function(err){
- self.uncaught(err);
- });
+ process.on('uncaughtException', uncaught);
return this;
};