Browse Source

Fix: uncaughtException was broken for main module

See: 635986e433
v0.7.4-release
Felix Geisendörfer 15 years ago
committed by Ryan Dahl
parent
commit
ef54777fa5
  1. 4
      src/node.js
  2. 9
      test/message/undefined_reference_in_new_context.out
  3. 10
      test/simple/test-exception-handler2.js

4
src/node.js

@ -749,7 +749,11 @@ if (process.argv[1]) {
process.argv[1] = path.join(cwd, process.argv[1]); process.argv[1] = path.join(cwd, process.argv[1]);
} }
// REMOVEME: nextTick should not be necessary. This hack to get
// test/simple/test-exception-handler2.js working.
process.nextTick(function() {
module.runMain(); module.runMain();
});
} else { } else {
// No arguments, run the repl // No arguments, run the repl
var repl = module.requireNative('repl'); var repl = module.requireNative('repl');

9
test/message/undefined_reference_in_new_context.out

@ -1,9 +1,8 @@
before before
node.js:*
*.js:* throw e;
*cript.runIn*Context(*); ^
*^
ReferenceError: foo is not defined ReferenceError: foo is not defined
at evalmachine.<anonymous>:* at evalmachine.<anonymous>:*
at *test/message/undefined_reference_in_new_context.js:* at *test/message/undefined_reference_in_new_context.js:*
@ -11,4 +10,6 @@ ReferenceError: foo is not defined
at Module._loadScriptSync (node.js:*) at Module._loadScriptSync (node.js:*)
at Module.loadSync (node.js:*) at Module.loadSync (node.js:*)
at Object.runMain (node.js:*) at Object.runMain (node.js:*)
at Array.<anonymous> (node.js:*)
at EventEmitter._tickCallback (node.js:*)
at node.js:* at node.js:*

10
test/simple/test-exception-handler2.js

@ -1,11 +1,21 @@
common = require("../common");
assert = common.assert
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err); console.log('Caught exception: ' + err);
}); });
var timeoutFired = false;
setTimeout(function () { setTimeout(function () {
console.log('This will still run.'); console.log('This will still run.');
timeoutFired = true;
}, 500); }, 500);
process.on('exit', function() {
assert.ok(timeoutFired);
});
// Intentionally cause an exception, but don't catch it. // Intentionally cause an exception, but don't catch it.
nonexistentFunc(); nonexistentFunc();
console.log('This will not run.'); console.log('This will not run.');

Loading…
Cancel
Save