mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
c3ff89920e
Add useful info about process.domain to error meesages in the uncaughtException event listener and the beforeExit event listener. Refactor code such as using template literals, and also make sure uncaughtException listner is detached after firing once to avoid endless loop in case of exception throw in the beforeExit event listner. PR-URL: https://github.com/nodejs/node/pull/18541 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
26 lines
731 B
JavaScript
26 lines
731 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const domain = require('domain');
|
|
const assert = require('assert');
|
|
|
|
const d = domain.create();
|
|
|
|
process.once('uncaughtException', common.mustCall(function onUncaught() {
|
|
assert.strictEqual(
|
|
process.domain, null,
|
|
'Domains stack should be empty in uncaughtException handler ' +
|
|
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
|
|
}));
|
|
|
|
process.on('beforeExit', common.mustCall(function onBeforeExit() {
|
|
assert.strictEqual(
|
|
process.domain, null,
|
|
'Domains stack should be empty in beforeExit handler ' +
|
|
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
|
|
}));
|
|
|
|
d.run(function() {
|
|
throw new Error('boom');
|
|
});
|