Done by not evaluating the code in the first tick.
This breaks one test in test-error-reporting.js but I believe this to be a
V8 error and I have reported it in
http://code.google.com/p/v8/issues/detail?id=764
// bootstrap main module.
-exports.runMain = function () {
+exports.runMain = function (filename) {
// Load the main module--the command line argument.
process.mainModule = new Module(".");
- process.mainModule.loadSync(process.argv[1]);
+ process.mainModule.load(filename, function (err) {
+ if (err) throw err;
+ });
}
f->Call(global, 1, args);
- if (try_catch.HasCaught()) {
- ReportException(try_catch, true);
- exit(11);
+ if (try_catch.HasCaught()) {
+ FatalException(try_catch);
}
}
process.argv[1] = path.join(cwd, process.argv[1]);
}
- module.runMain();
+ module.runMain(process.argv[1]);
} else {
// No arguments, run the repl
var repl = module.requireNative('repl');
});
-// Trying to JSON.parse(undefined)
-errExec('throws_error2.js', function (err, stdout, stderr) {
+// Trying to JSON.parse(undefined) in nextTick
+errExec('throws_error3.js', function (err, stdout, stderr) {
assert.ok(/JSON/.test(stderr));
});
-// Trying to JSON.parse(undefined) in nextTick
-errExec('throws_error3.js', function (err, stdout, stderr) {
+// Trying to JSON.parse(undefined)
+errExec('throws_error2.js', function (err, stdout, stderr) {
assert.ok(/JSON/.test(stderr));
});
--- /dev/null
+require('../common')
+
+process.addListener('uncaughtException', function (err) {
+ puts('Caught exception: ' + err);
+});
+
+setTimeout(function () {
+ puts('This will still run.');
+}, 500);
+
+// Intentionally cause an exception, but don't catch it.
+nonexistentFunc();
+puts('This will not run.');