Skip to content

Commit

Permalink
async Pending handling
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Sep 27, 2019
1 parent f8f3542 commit 9f9894a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/runnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,16 @@ Runnable.prototype.run = function(fn) {
throw new Pending('async skip; aborting execution');
};

if (this.allowUncaught) {
return callFnAsync(this.fn);
}
try {
callFnAsync(this.fn);
} catch (err) {
// handles async runnables which actually run synchronously
emitted = true;
if (err instanceof Pending) {
return; // done() is already called in this.skip()
} else if (this.allowUncaught) {
throw err;
}
done(Runnable.toValueOrError(err));
}
return;
Expand Down
3 changes: 2 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,9 @@ Runner.prototype.run = function(fn) {
process.removeListener('uncaughtException', uncaught);
process.on('uncaughtException', function(err) {
if (err instanceof Pending) {
// return; eslint error
return;
}
throw err;
});
fn(self.failures);
});
Expand Down

0 comments on commit 9f9894a

Please sign in to comment.