Skip to content
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

Move removal of uncaughtException handler into end callback #4329

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/runner.js
Expand Up @@ -989,6 +989,7 @@ Runner.prototype.run = function(fn, opts) {
fn = fn || function() {};

function start() {
self._addEventListener(process, 'uncaughtException', self.uncaught);
debug('run(): starting');
// If there is an `only` filter
if (rootSuite.hasOnly()) {
Expand Down Expand Up @@ -1027,11 +1028,9 @@ Runner.prototype.run = function(fn, opts) {
debug(constants.EVENT_RUN_END);
debug('run(): emitted %s', constants.EVENT_RUN_END);
fn(self.failures);
self._removeEventListener(process, 'uncaughtException', self.uncaught);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the uncaught exception handler here is incorrect, too early, IMO. There can be exceptions bubbling up after runner's end. We even have a check for this (STATE_STOPPED) in Runner#_uncaught.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a runner 'end's, then results are likely to have been reported based on that runner. If a test could error post-end, it's too late to include it in results... Simultaneously, if a test still has outstanding actions like that, the runner probably shouldn't be 'end'ing!

});

self._removeEventListener(process, 'uncaughtException', self.uncaught);
self._addEventListener(process, 'uncaughtException', self.uncaught);

if (this._delay) {
// for reporters, I guess.
// might be nice to debounce some dots while we wait.
Expand Down