Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

domains mishandle thrown nulls #6757

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/domain.js
Expand Up @@ -56,8 +56,10 @@ var listenerObj = {
if (domain._disposed)
return true;

er.domain = domain;
er.domainThrown = true;
if (!util.isPrimitive(er)) {
er.domain = domain;
er.domainThrown = true;
}
// wrap this in a try/catch so we don't get infinite throwing
try {
// One of three things will happen here.
Expand Down
17 changes: 17 additions & 0 deletions test/simple/test-domain.js
Expand Up @@ -261,3 +261,20 @@ assert.equal(result, 'return value');
var fst = fs.createReadStream('stream for nonexistent file')
d.add(fst)
expectCaught++;


[42, null, undefined, false, function(){}, 'string'].forEach(function(something) {
var d = new domain.Domain();
d.run(function() {
process.nextTick(function() {
throw something;
});
expectCaught++;
});

d.on('error', function(er) {
assert.strictEqual(something, er);
caught++;
});
});