diff options
Diffstat (limited to 'lib/domain.js')
-rw-r--r-- | lib/domain.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/domain.js b/lib/domain.js index 80a64c64bf..afaa922ebe 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -67,13 +67,13 @@ Domain.prototype.enter = function() { }; Domain.prototype.exit = function() { - if (this._disposed) return; + // skip disposed domains, as usual, but also don't do anything if this + // domain is not on the stack. + var index = stack.lastIndexOf(this); + if (this._disposed || index === -1) return; // exit all domains until this one. - var d; - do { - d = stack.pop(); - } while (d && d !== this); + stack.splice(index); exports.active = stack[stack.length - 1]; process.domain = exports.active; |