Skip to content
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
Next Next commit
process: nextTick should not be handled lazily
  • Loading branch information
yorkie committed Nov 16, 2015
commit 29d8578be0ca831f641fdd9d87c70850bca39f52
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