Skip to content

Commit 5038f40

Browse files
committed
node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
1 parent 25ba971 commit 5038f40

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

doc/node.1

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ and servers.
5656

5757
--trace-deprecation show stack traces on deprecations
5858

59+
--throw-deprecation throw errors on deprecations
60+
5961
--v8-options print v8 command line options
6062

6163
--max-stack-size=val set max v8 stack size (bytes)

lib/util.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ exports.deprecate = function(fn, msg) {
6565
var warned = false;
6666
function deprecated() {
6767
if (!warned) {
68-
if (process.traceDeprecation) {
68+
if (process.throwDeprecation) {
69+
throw new Error(msg);
70+
} else if (process.traceDeprecation) {
6971
console.trace(msg);
7072
} else {
7173
console.error(msg);

src/node.cc

+9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static Persistent<String> disposed_symbol;
127127
static bool print_eval = false;
128128
static bool force_repl = false;
129129
static bool trace_deprecation = false;
130+
static bool throw_deprecation = false;
130131
static char *eval_string = NULL;
131132
static int option_end_index = 0;
132133
static bool use_debug_agent = false;
@@ -2414,6 +2415,11 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
24142415
process->Set(String::NewSymbol("noDeprecation"), True());
24152416
}
24162417

2418+
// --throw-deprecation
2419+
if (throw_deprecation) {
2420+
process->Set(String::NewSymbol("throwDeprecation"), True());
2421+
}
2422+
24172423
// --trace-deprecation
24182424
if (trace_deprecation) {
24192425
process->Set(String::NewSymbol("traceDeprecation"), True());
@@ -2666,6 +2672,9 @@ static void ParseArgs(int argc, char **argv) {
26662672
} else if (strcmp(arg, "--trace-deprecation") == 0) {
26672673
argv[i] = const_cast<char*>("");
26682674
trace_deprecation = true;
2675+
} else if (strcmp(arg, "--throw-deprecation") == 0) {
2676+
argv[i] = const_cast<char*>("");
2677+
throw_deprecation = true;
26692678
} else if (argv[i][0] != '-') {
26702679
break;
26712680
}

src/node.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@
359359
var msg = '(node) warning: Recursive process.nextTick detected. ' +
360360
'This will break in the next version of node. ' +
361361
'Please use setImmediate for recursive deferral.';
362-
if (process.traceDeprecation)
362+
if (process.throwDeprecation)
363+
throw new Error(msg);
364+
else if (process.traceDeprecation)
363365
console.trace(msg);
364366
else
365367
console.error(msg);

0 commit comments

Comments
 (0)