domains mishandle thrown nulls #6757

Closed
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+21 −2
Split
View
@@ -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.
View
@@ -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++;
+ });
+});
+