mirror of https://github.com/lukechilds/node.git
Browse Source
Clear domains stack __even if no domain error handler is set__ so that code running in the process' uncaughtException handler, or any code that may be executed when an error is thrown and not caught and that is not the domain's error handler, doesn't run in the context of the domain within which the error was thrown. PR: #4659 PR-URL: https://github.com/nodejs/node/pull/4659 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>process-exit-stdio-flushing
2 changed files with 31 additions and 15 deletions
@ -0,0 +1,22 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const domain = require('domain'); |
|||
const assert = require('assert'); |
|||
|
|||
const d = domain.create(); |
|||
|
|||
process.on('uncaughtException', common.mustCall(function onUncaught() { |
|||
assert.equal(process.domain, null, |
|||
'domains stack should be empty in uncaughtException handler'); |
|||
})); |
|||
|
|||
process.on('beforeExit', common.mustCall(function onBeforeExit() { |
|||
assert.equal(process.domain, null, |
|||
'domains stack should be empty in beforeExit handler'); |
|||
})); |
|||
|
|||
d.run(function() { |
|||
throw new Error('boom'); |
|||
}); |
|||
|
Loading…
Reference in new issue