Browse Source

domain: don't crash on "throw null"

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
v0.11.13-release
Alex Kocharin 11 years ago
committed by Trevor Norris
parent
commit
42a33c1bb8
  1. 6
      lib/domain.js
  2. 15
      test/simple/test-domain.js

6
lib/domain.js

@ -85,8 +85,10 @@ Domain.prototype._errorHandler = function errorHandler(er) {
if (this._disposed)
return true;
er.domain = this;
er.domainThrown = true;
if (!util.isPrimitive(er)) {
er.domain = this;
er.domainThrown = true;
}
// wrap this in a try/catch so we don't get infinite throwing
try {
// One of three things will happen here.

15
test/simple/test-domain.js

@ -261,3 +261,18 @@ assert.equal(result, 'return value');
var fst = fs.createReadStream('stream for nonexistent file')
d.add(fst)
expectCaught++;
[42, null, , 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++;
});
});

Loading…
Cancel
Save