mirror of https://github.com/nodejs/node.git
domain: don't crash on "throw null"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>pull/5010/head
parent
006d42786e
commit
42a33c1bb8
|
@ -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.
|
||||
|
|
|
@ -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…
Reference in New Issue