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

process: nextTick should not be handled lazily #3860

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@
// on the way out, don't bother. it won't get fired anyway.
if (process._exiting)
return;
if (typeof callback !== 'function')
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this if above the previous if for a more consistent throwing experience.

throw new Error('callback is not a function');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this a TypeError


var args;
if (arguments.length > 1) {
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-next-tick-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ process.nextTick(function() {
order.push('C');
});

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use assert.throws() here.

process.nextTick();
} catch (e) {
// should handle this error at try...catch
if (!e) {
assert.fail();
}
}

process.on('uncaughtException', function() {
if (!exceptionHandled) {
exceptionHandled = true;
Expand Down