Skip to content

Commit

Permalink
test: add useful info to error msg and refactor
Browse files Browse the repository at this point in the history
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: #18541
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
chinhuang007 authored and BridgeAR committed Feb 12, 2018
1 parent 2287dea commit c3ff899
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -6,15 +6,18 @@ const assert = require('assert');


const d = domain.create(); const d = domain.create();


process.on('uncaughtException', common.mustCall(function onUncaught() { process.once('uncaughtException', common.mustCall(function onUncaught() {
assert.strictEqual( assert.strictEqual(
process.domain, null, process.domain, null,
'domains stack should be empty in uncaughtException handler'); '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() { process.on('beforeExit', common.mustCall(function onBeforeExit() {
assert.strictEqual(process.domain, null, assert.strictEqual(
'domains stack should be empty in beforeExit handler'); 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() { d.run(function() {
Expand Down

0 comments on commit c3ff899

Please sign in to comment.