Skip to content

Commit ef54777

Browse files
felixgery
authored andcommitted
Fix: uncaughtException was broken for main module
See: http://github.com/ry/node/commit/635986e4338cf34cf8e1abc4343ffd69d109bb4e
1 parent 17f3ffa commit ef54777

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/node.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,11 @@ if (process.argv[1]) {
749749
process.argv[1] = path.join(cwd, process.argv[1]);
750750
}
751751

752-
module.runMain();
752+
// REMOVEME: nextTick should not be necessary. This hack to get
753+
// test/simple/test-exception-handler2.js working.
754+
process.nextTick(function() {
755+
module.runMain();
756+
});
753757
} else {
754758
// No arguments, run the repl
755759
var repl = module.requireNative('repl');
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
before
22

3-
4-
*.js:*
5-
*cript.runIn*Context(*);
6-
*^
3+
node.js:*
4+
throw e;
5+
^
76
ReferenceError: foo is not defined
87
at evalmachine.<anonymous>:*
98
at *test/message/undefined_reference_in_new_context.js:*
109
at Module._compile (node.js:*)
1110
at Module._loadScriptSync (node.js:*)
1211
at Module.loadSync (node.js:*)
1312
at Object.runMain (node.js:*)
13+
at Array.<anonymous> (node.js:*)
14+
at EventEmitter._tickCallback (node.js:*)
1415
at node.js:*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
common = require("../common");
2+
assert = common.assert
3+
14
process.on('uncaughtException', function (err) {
25
console.log('Caught exception: ' + err);
36
});
47

8+
var timeoutFired = false;
59
setTimeout(function () {
610
console.log('This will still run.');
11+
timeoutFired = true;
712
}, 500);
813

14+
process.on('exit', function() {
15+
assert.ok(timeoutFired);
16+
});
17+
918
// Intentionally cause an exception, but don't catch it.
1019
nonexistentFunc();
1120
console.log('This will not run.');
21+

0 commit comments

Comments
 (0)