Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

core: Remove the nextTick for running the main file

Not necessary, since we can handle the error properly on the first tick
now, even if there are event listeners, etc.

Additionally, this removes the unnecessary "_needTickCallback" from
startup, since Module.loadMain() will kick off a nextTick callback right
after it runs the main module.
  • Loading branch information...
commit 215b530b31ed91fbd037f4787c37a18b11b3a049 1 parent 95862b2
@isaacs authored
View
2  lib/module.js
@@ -495,6 +495,8 @@ Module._extensions['.node'] = process.dlopen;
Module.runMain = function() {
// Load the main module--the command line argument.
Module._load(process.argv[1], null, true);
+ // Handle any nextTicks added in the first tick of the program
+ process._tickCallback();
};
Module._initPaths = function() {
View
6 src/node.js
@@ -114,10 +114,8 @@
setTimeout(Module.runMain, debugTimeout);
} else {
- // REMOVEME: nextTick should not be necessary. This hack to get
- // test/simple/test-exception-handler2.js working.
// Main entry point into most programs:
- process.nextTick(Module.runMain);
+ Module.runMain();
}
} else {
@@ -156,8 +154,6 @@
});
}
}
-
- process._needTickCallback();
}
startup.globalVariables = function() {
View
6 test/message/error_exit.out
@@ -9,6 +9,6 @@ AssertionError: 1 == 2
at Object.Module._extensions..js (module.js:*:*)
at Module.load (module.js:*:*)
at Function.Module._load (module.js:*:*)
- at Module.runMain (module.js:*:*)
- at _tickCallback (node.js:*:*)
- at process._tickFromSpinner (node.js:*:*)
+ at Function.Module.runMain (module.js:*:*)
+ at startup (node.js:*:*)
+ at node.js:*:*
View
4 test/message/max_tick_depth.out
@@ -7,8 +7,8 @@ tick 15
tick 14
tick 13
tick 12
-(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 11
+(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 10
tick 9
tick 8
@@ -18,6 +18,6 @@ tick 5
tick 4
tick 3
tick 2
-(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 1
+(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 0
View
13 test/message/max_tick_depth_trace.out
@@ -7,13 +7,14 @@ tick 15
tick 14
tick 13
tick 12
+tick 11
Trace: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
at maxTickWarn (node.js:*:*)
- at process.nextTick (node.js:*:*
+ at process.nextTick (node.js:*:*)
at f (*test*message*max_tick_depth_trace.js:*:*)
- at _tickCallback (node.js:*:*)
- at process._tickFromSpinner (node.js:*:*)
-tick 11
+ at process._tickCallback (node.js:*:*)
+ at startup (node.js:*:*)
+ at node.js:*:*
tick 10
tick 9
tick 8
@@ -23,11 +24,11 @@ tick 5
tick 4
tick 3
tick 2
+tick 1
Trace: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
at maxTickWarn (node.js:*:*)
- at process.nextTick (node.js:*:*
+ at process.nextTick (node.js:*:*)
at f (*test*message*max_tick_depth_trace.js:*:*)
at _tickCallback (node.js:*:*)
at process._tickFromSpinner (node.js:*:*)
-tick 1
tick 0
View
6 test/message/nexttick_throw.out
@@ -1,7 +1,9 @@
+
*test*message*nexttick_throw.js:*
undefined_reference_error_maker;
^
ReferenceError: undefined_reference_error_maker is not defined
at *test*message*nexttick_throw.js:*:*
- at _tickCallback (node.js:*:*)
- at process._tickFromSpinner (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
+ at startup (node.js:*:*)
+ at node.js:*:*
View
8 test/message/undefined_reference_in_new_context.out
@@ -9,7 +9,7 @@ ReferenceError: foo is not defined
at Module._compile (module.js:*)
at *..js (module.js:*)
at Module.load (module.js:*)
- at *._load (module.js:*)
- at Module.runMain (module.js:*)
- at _tickCallback (node.js:*)
- at *._tickFromSpinner (node.js:*)
+ at Function.Module._load (module.js:*:*)
+ at Function.Module.runMain (module.js:*:*)
+ at startup (node.js:*:*)
+ at node.js:*:*
View
18 test/simple/test-domain.js
@@ -110,6 +110,12 @@ d.on('error', function(er) {
assert.ok(!er.domainBound);
break;
+ case 'nextTick execution loop':
+ assert.equal(er.domain, d);
+ assert.ok(!er.domainEmitter);
+ assert.ok(!er.domainBound);
+ break;
+
default:
console.error('unexpected error, throwing %j', er.message, er);
throw er;
@@ -127,6 +133,18 @@ process.on('exit', function() {
});
+
+// revert to using the domain when a callback is passed to nextTick in
+// the middle of a tickCallback loop
+d.run(function() {
+ process.nextTick(function() {
+ throw new Error('nextTick execution loop');
+ });
+});
+expectCaught++;
+
+
+
// catch thrown errors no matter how many times we enter the event loop
// this only uses implicit binding, except for the first function
// passed to d.run(). The rest are implicitly bound by virtue of being

0 comments on commit 215b530

Please sign in to comment.
Something went wrong with that request. Please try again.