node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
This commit is contained in:
parent
25ba971f41
commit
5038f40185
@ -56,6 +56,8 @@ and servers.
|
|||||||
|
|
||||||
--trace-deprecation show stack traces on deprecations
|
--trace-deprecation show stack traces on deprecations
|
||||||
|
|
||||||
|
--throw-deprecation throw errors on deprecations
|
||||||
|
|
||||||
--v8-options print v8 command line options
|
--v8-options print v8 command line options
|
||||||
|
|
||||||
--max-stack-size=val set max v8 stack size (bytes)
|
--max-stack-size=val set max v8 stack size (bytes)
|
||||||
|
@ -65,7 +65,9 @@ exports.deprecate = function(fn, msg) {
|
|||||||
var warned = false;
|
var warned = false;
|
||||||
function deprecated() {
|
function deprecated() {
|
||||||
if (!warned) {
|
if (!warned) {
|
||||||
if (process.traceDeprecation) {
|
if (process.throwDeprecation) {
|
||||||
|
throw new Error(msg);
|
||||||
|
} else if (process.traceDeprecation) {
|
||||||
console.trace(msg);
|
console.trace(msg);
|
||||||
} else {
|
} else {
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
|
@ -127,6 +127,7 @@ static Persistent<String> disposed_symbol;
|
|||||||
static bool print_eval = false;
|
static bool print_eval = false;
|
||||||
static bool force_repl = false;
|
static bool force_repl = false;
|
||||||
static bool trace_deprecation = false;
|
static bool trace_deprecation = false;
|
||||||
|
static bool throw_deprecation = false;
|
||||||
static char *eval_string = NULL;
|
static char *eval_string = NULL;
|
||||||
static int option_end_index = 0;
|
static int option_end_index = 0;
|
||||||
static bool use_debug_agent = false;
|
static bool use_debug_agent = false;
|
||||||
@ -2414,6 +2415,11 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
process->Set(String::NewSymbol("noDeprecation"), True());
|
process->Set(String::NewSymbol("noDeprecation"), True());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --throw-deprecation
|
||||||
|
if (throw_deprecation) {
|
||||||
|
process->Set(String::NewSymbol("throwDeprecation"), True());
|
||||||
|
}
|
||||||
|
|
||||||
// --trace-deprecation
|
// --trace-deprecation
|
||||||
if (trace_deprecation) {
|
if (trace_deprecation) {
|
||||||
process->Set(String::NewSymbol("traceDeprecation"), True());
|
process->Set(String::NewSymbol("traceDeprecation"), True());
|
||||||
@ -2666,6 +2672,9 @@ static void ParseArgs(int argc, char **argv) {
|
|||||||
} else if (strcmp(arg, "--trace-deprecation") == 0) {
|
} else if (strcmp(arg, "--trace-deprecation") == 0) {
|
||||||
argv[i] = const_cast<char*>("");
|
argv[i] = const_cast<char*>("");
|
||||||
trace_deprecation = true;
|
trace_deprecation = true;
|
||||||
|
} else if (strcmp(arg, "--throw-deprecation") == 0) {
|
||||||
|
argv[i] = const_cast<char*>("");
|
||||||
|
throw_deprecation = true;
|
||||||
} else if (argv[i][0] != '-') {
|
} else if (argv[i][0] != '-') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,9 @@
|
|||||||
var msg = '(node) warning: Recursive process.nextTick detected. ' +
|
var msg = '(node) warning: Recursive process.nextTick detected. ' +
|
||||||
'This will break in the next version of node. ' +
|
'This will break in the next version of node. ' +
|
||||||
'Please use setImmediate for recursive deferral.';
|
'Please use setImmediate for recursive deferral.';
|
||||||
if (process.traceDeprecation)
|
if (process.throwDeprecation)
|
||||||
|
throw new Error(msg);
|
||||||
|
else if (process.traceDeprecation)
|
||||||
console.trace(msg);
|
console.trace(msg);
|
||||||
else
|
else
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user