Browse Source

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.

Fix #4856
v0.9.11-release
isaacs 12 years ago
parent
commit
875e4a0c59
  1. 2
      lib/module.js
  2. 6
      src/node.js
  3. 6
      test/message/error_exit.out
  4. 4
      test/message/max_tick_depth.out
  5. 14
      test/message/max_tick_depth_trace.out
  6. 7
      test/message/nexttick_throw.out
  7. 8
      test/message/undefined_reference_in_new_context.out
  8. 18
      test/simple/test-domain.js

2
lib/module.js

@ -495,6 +495,8 @@ Module._extensions['.node'] = process.dlopen;
Module.runMain = function() { Module.runMain = function() {
// Load the main module--the command line argument. // Load the main module--the command line argument.
Module._load(process.argv[1], null, true); Module._load(process.argv[1], null, true);
// Handle any nextTicks added in the first tick of the program
process._tickCallback();
}; };
Module._initPaths = function() { Module._initPaths = function() {

6
src/node.js

@ -114,10 +114,8 @@
setTimeout(Module.runMain, debugTimeout); setTimeout(Module.runMain, debugTimeout);
} else { } else {
// REMOVEME: nextTick should not be necessary. This hack to get
// test/simple/test-exception-handler2.js working.
// Main entry point into most programs: // Main entry point into most programs:
process.nextTick(Module.runMain); Module.runMain();
} }
} else { } else {
@ -156,8 +154,6 @@
}); });
} }
} }
process._needTickCallback();
} }
startup.globalVariables = function() { startup.globalVariables = function() {

6
test/message/error_exit.out

@ -9,6 +9,6 @@ AssertionError: 1 == 2
at Object.Module._extensions..js (module.js:*:*) at Object.Module._extensions..js (module.js:*:*)
at Module.load (module.js:*:*) at Module.load (module.js:*:*)
at Function.Module._load (module.js:*:*) at Function.Module._load (module.js:*:*)
at Module.runMain (module.js:*:*) at Function.Module.runMain (module.js:*:*)
at _tickCallback (node.js:*:*) at startup (node.js:*:*)
at process._tickFromSpinner (node.js:*:*) at node.js:*:*

4
test/message/max_tick_depth.out

@ -7,8 +7,8 @@ tick 15
tick 14 tick 14
tick 13 tick 13
tick 12 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 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 10
tick 9 tick 9
tick 8 tick 8
@ -18,6 +18,6 @@ tick 5
tick 4 tick 4
tick 3 tick 3
tick 2 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 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 tick 0

14
test/message/max_tick_depth_trace.out

@ -7,13 +7,15 @@ tick 15
tick 14 tick 14
tick 13 tick 13
tick 12 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. 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 maxTickWarn (node.js:*:*)
at process.nextTick (node.js:*:* at process.nextTick (node.js:*:*)
at f (*test*message*max_tick_depth_trace.js:*:*) at f (*test*message*max_tick_depth_trace.js:*:*)
at _tickCallback (node.js:*:*) at process._tickCallback (node.js:*:*)
at process._tickFromSpinner (node.js:*:*) at Function.Module.runMain (module.js:*:*)
tick 11 at startup (node.js:*:*)
at node.js:*:*
tick 10 tick 10
tick 9 tick 9
tick 8 tick 8
@ -23,11 +25,11 @@ tick 5
tick 4 tick 4
tick 3 tick 3
tick 2 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. 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 maxTickWarn (node.js:*:*)
at process.nextTick (node.js:*:* at process.nextTick (node.js:*:*)
at f (*test*message*max_tick_depth_trace.js:*:*) at f (*test*message*max_tick_depth_trace.js:*:*)
at _tickCallback (node.js:*:*) at _tickCallback (node.js:*:*)
at process._tickFromSpinner (node.js:*:*) at process._tickFromSpinner (node.js:*:*)
tick 1
tick 0 tick 0

7
test/message/nexttick_throw.out

@ -1,7 +1,10 @@
*test*message*nexttick_throw.js:* *test*message*nexttick_throw.js:*
undefined_reference_error_maker; undefined_reference_error_maker;
^ ^
ReferenceError: undefined_reference_error_maker is not defined ReferenceError: undefined_reference_error_maker is not defined
at *test*message*nexttick_throw.js:*:* at *test*message*nexttick_throw.js:*:*
at _tickCallback (node.js:*:*) at process._tickCallback (node.js:*:*)
at process._tickFromSpinner (node.js:*:*) at Function.Module.runMain (module.js:*:*)
at startup (node.js:*:*)
at node.js:*:*

8
test/message/undefined_reference_in_new_context.out

@ -9,7 +9,7 @@ ReferenceError: foo is not defined
at Module._compile (module.js:*) at Module._compile (module.js:*)
at *..js (module.js:*) at *..js (module.js:*)
at Module.load (module.js:*) at Module.load (module.js:*)
at *._load (module.js:*) at Function.Module._load (module.js:*:*)
at Module.runMain (module.js:*) at Function.Module.runMain (module.js:*:*)
at _tickCallback (node.js:*) at startup (node.js:*:*)
at *._tickFromSpinner (node.js:*) at node.js:*:*

18
test/simple/test-domain.js

@ -110,6 +110,12 @@ d.on('error', function(er) {
assert.ok(!er.domainBound); assert.ok(!er.domainBound);
break; break;
case 'nextTick execution loop':
assert.equal(er.domain, d);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
default: default:
console.error('unexpected error, throwing %j', er.message, er); console.error('unexpected error, throwing %j', er.message, er);
throw 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 // catch thrown errors no matter how many times we enter the event loop
// this only uses implicit binding, except for the first function // this only uses implicit binding, except for the first function
// passed to d.run(). The rest are implicitly bound by virtue of being // passed to d.run(). The rest are implicitly bound by virtue of being

Loading…
Cancel
Save