Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

domain: don't crash on "throw null"

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information...
commit 42a33c1bb869a8fd64525ae282a0ab1d859218a9 1 parent 006d427
@rlidwka rlidwka authored trevnorris committed
Showing with 19 additions and 2 deletions.
  1. +4 −2 lib/domain.js
  2. +15 −0 test/simple/test-domain.js
View
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.
View
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++;
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.