diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-30 02:30:13 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-30 17:12:23 +0400 |
commit | b221fe9b29f7dd834af9716e077bc05a05156d64 (patch) | |
tree | 3b8705313e36861230a4e0e05e1f58030915c406 /lib | |
parent | ca4b91a1d00255da852ccfb856e2beda8a7030f7 (diff) |
timers: add v0.4 compatibility hack
If a timer callback throws and the user's uncaughtException handler ignores the
exception, other timers that expire on the current tick should still run.
If #2582 goes through, this hack should be removed.
Fixes #2631.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/timers.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/timers.js b/lib/timers.js index 7a57d342776..c5592bf0a20 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -81,7 +81,21 @@ function insert(item, msecs) { } else { L.remove(first); assert(first !== L.peek(list)); - if (first._onTimeout) first._onTimeout(); + + 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. + // + // https://github.com/joyent/node/issues/2631 + try { + first._onTimeout(); + } catch (e) { + if (!process.listeners('uncaughtException').length) throw e; + process.emit('uncaughtException', e); + } } } |