mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 18:29:01 +00:00

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>
23 lines
552 B
JavaScript
23 lines
552 B
JavaScript
'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');
|
|
});
|
|
|