joyent/node — pull request #4621 by cxreg (2013-01-18 04:17:30+00:00)
Title: always empty domain stack when handling exceptions

Re-filing PR #4557 based against master

Make domains a little safer by avoiding potentially unbounded stack bloat

The following code will cause the stack to grow:

var d = require("domain");
....
setTimeout(function() {
console.log('domain stack length is now ' + d._stack.length);
}, 100);
....
d.create().run(function() {
d.create().run(function() {
d.create().run(function() {
d.create().on("error", function(e) {
console.log("caught " + e)
}).run(function() {
throw new Error("died")
})
})
})
})