summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-12-26 12:28:33 -0800
committerisaacs <i@izs.me>2012-12-29 10:37:30 -0800
commit4401bb47bfa4fe72c2755c428577903ece5cfaa0 (patch)
tree84a4f31447498d9e165fd998b7e7547ab5f60846 /lib
parentc6e958d44d6674676581ced360530f85508121a2 (diff)
downloadnode-new-4401bb47bfa4fe72c2755c428577903ece5cfaa0.tar.gz
domain: Do not use uncaughtException handler
This adds a process._fatalException method which is called into from C++ in order to either emit the 'uncaughtException' method, or emit 'error' on the active domain. The 'uncaughtException' event is an implementation detail that it would be nice to deprecate one day, so exposing it as part of the domain machinery is not ideal. Fix #4375
Diffstat (limited to 'lib')
-rw-r--r--lib/domain.js21
-rw-r--r--lib/timers.js29
2 files changed, 17 insertions, 33 deletions
diff --git a/lib/domain.js b/lib/domain.js
index 4fefb913c8..32259d7a73 100644
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -46,27 +46,6 @@ exports._stack = stack;
exports.active = null;
-// loading this file the first time sets up the global
-// uncaughtException handler.
-process.on('uncaughtException', uncaughtHandler);
-
-function uncaughtHandler(er) {
- // if there's an active domain, then handle this there.
- // Note that if this error emission throws, then it'll just crash.
- if (exports.active && !exports.active._disposed) {
- util._extend(er, {
- domain: exports.active,
- domain_thrown: true
- });
- exports.active.emit('error', er);
- if (exports.active) exports.active.exit();
- } else if (process.listeners('uncaughtException').length === 1) {
- // if there are other handlers, then they'll take care of it.
- // but if not, then we need to crash now.
- throw er;
- }
-}
-
inherits(Domain, EventEmitter);
function Domain() {
diff --git a/lib/timers.js b/lib/timers.js
index 48353c04ef..8ec6b2c852 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -86,23 +86,28 @@ function insert(item, msecs) {
if (!first._onTimeout) continue;
- // v0.4 compatibility: if the timer callback throws and the user's
- // uncaughtException handler ignores the exception, other timers that
- // expire on this tick should still run. If #2582 goes through, this
- // hack should be removed.
+ // v0.4 compatibility: if the timer callback throws and the
+ // domain or uncaughtException handler ignore the exception,
+ // other timers that expire on this tick should still run.
//
// https://github.com/joyent/node/issues/2631
- if (first.domain) {
- if (first.domain._disposed) continue;
- first.domain.enter();
- }
+ var domain = first.domain;
+ if (domain && domain._disposed) continue;
try {
+ if (domain)
+ domain.enter();
+ var threw = true;
first._onTimeout();
- } catch (e) {
- if (!process.listeners('uncaughtException').length) throw e;
- process.emit('uncaughtException', e);
+ if (domain)
+ domain.exit();
+ threw = false;
+ } finally {
+ if (threw) {
+ process.nextTick(function() {
+ list.ontimeout();
+ });
+ }
}
- if (first.domain) first.domain.exit();
}
}