process: throw on non-function to nextTick()
This commit causes process.nextTick() to throw when its callback argument is not a function. PR-URL: https://github.com/nodejs/node/pull/3860 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
This commit is contained in:
parent
339d3840c8
commit
72e3dd9f43
@ -486,6 +486,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nextTick(callback) {
|
function nextTick(callback) {
|
||||||
|
if (typeof callback !== 'function')
|
||||||
|
throw new TypeError('callback is not a function');
|
||||||
// on the way out, don't bother. it won't get fired anyway.
|
// on the way out, don't bother. it won't get fired anyway.
|
||||||
if (process._exiting)
|
if (process._exiting)
|
||||||
return;
|
return;
|
||||||
|
@ -20,6 +20,22 @@ process.nextTick(function() {
|
|||||||
order.push('C');
|
order.push('C');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function testNextTickWith(val) {
|
||||||
|
assert.throws(
|
||||||
|
function() {
|
||||||
|
process.nextTick(val);
|
||||||
|
},
|
||||||
|
TypeError
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
testNextTickWith(false);
|
||||||
|
testNextTickWith(true);
|
||||||
|
testNextTickWith(1);
|
||||||
|
testNextTickWith('str');
|
||||||
|
testNextTickWith({});
|
||||||
|
testNextTickWith([]);
|
||||||
|
|
||||||
process.on('uncaughtException', function() {
|
process.on('uncaughtException', function() {
|
||||||
if (!exceptionHandled) {
|
if (!exceptionHandled) {
|
||||||
exceptionHandled = true;
|
exceptionHandled = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user