-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uncaughtException: fix "--allow-uncaught" with "this.skip()" #4030
Conversation
I will do some additional testing and then merge this PR within the next few days. |
742daeb
to
a1bd5dd
Compare
@@ -910,6 +915,12 @@ Runner.prototype.run = function(fn) { | |||
this.on(constants.EVENT_RUN_END, function() { | |||
debug(constants.EVENT_RUN_END); | |||
process.removeListener('uncaughtException', uncaught); | |||
process.on('uncaughtException', function(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is adding a new, unique uncaughtException
handler every time the end
event of a runner is called - this means for every finished runner, a new handler gets added (which is never removed). This, in turn, causes a Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
warning to be fired by node.
:(
Description
mocha --allow-uncaught test.js
silently aborts execution after the firstthis.skip()
:Our docu states:
We achieve this abortion of the test/hook execution by throwing a
Pending
exception. In async scenarios this results in an intendeduncaughtException
which has to be swallowed somehow. Obviously--allow-uncaught
does not distinguish correctly between "bad"uncaughtException
(user code) and "good"uncaughtException
(this.skip()
).Description of the Change
--allow-uncaught
, we never allow thePending
exceptions to propagate.Runnable#skip()
we set the test to pending and immediately catch/swallow thePending
exception (sync scenario).this.skip()
we register an addionaluncaughtException
handler for exceptions bubbling up after EVENT_RUN_END.Pending
is to abort the test execution, we don't use it for anything else.