Skip to content

Commit e9c9200

Browse files
chinhuang007MylesBorins
authored andcommitted
test: add useful info to error msg and refactor
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 35ce3a8 commit e9c9200

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/parallel/test-domain-stack-empty-in-process-uncaughtexception.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ const assert = require('assert');
66

77
const d = domain.create();
88

9-
process.on('uncaughtException', common.mustCall(function onUncaught() {
9+
process.once('uncaughtException', common.mustCall(function onUncaught() {
1010
assert.strictEqual(
1111
process.domain, null,
12-
'domains stack should be empty in uncaughtException handler');
12+
'Domains stack should be empty in uncaughtException handler ' +
13+
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
1314
}));
1415

1516
process.on('beforeExit', common.mustCall(function onBeforeExit() {
16-
assert.strictEqual(process.domain, null,
17-
'domains stack should be empty in beforeExit handler');
17+
assert.strictEqual(
18+
process.domain, null,
19+
'Domains stack should be empty in beforeExit handler ' +
20+
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
1821
}));
1922

2023
d.run(function() {

0 commit comments

Comments
 (0)