mirror of https://github.com/lukechilds/node.git
Browse Source
If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode. This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode. Semver: patch PR-URL: https://github.com/iojs/io.js/pull/922 Fixes: https://github.com/iojs/io.js/issues/836 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>v1.8.0-commit
Chris Dickinson
10 years ago
6 changed files with 154 additions and 2 deletions
@ -0,0 +1,109 @@ |
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var spawn = require('child_process').spawn; |
|||
|
|||
var tests = [ |
|||
nextTick, |
|||
timer, |
|||
timerPlusNextTick, |
|||
firstRun, |
|||
netServer |
|||
] |
|||
|
|||
tests.forEach(function(test) { |
|||
console.log(test.name); |
|||
var child = spawn(process.execPath, [ |
|||
'--abort-on-uncaught-exception', |
|||
'-e', |
|||
'(' + test + ')()', |
|||
common.PORT |
|||
]); |
|||
child.stderr.pipe(process.stderr); |
|||
child.stdout.pipe(process.stdout); |
|||
child.on('exit', function(code) { |
|||
assert.strictEqual(code, 0); |
|||
}); |
|||
}); |
|||
|
|||
function nextTick() { |
|||
var domain = require('domain'); |
|||
var d = domain.create(); |
|||
|
|||
d.on('error', function(err) { |
|||
console.log('ok'); |
|||
process.exit(0); |
|||
}); |
|||
d.run(function() { |
|||
process.nextTick(function() { |
|||
throw new Error('exceptional!'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
function timer() { |
|||
var domain = require('domain'); |
|||
var d = domain.create(); |
|||
|
|||
d.on('error', function(err) { |
|||
console.log('ok'); |
|||
process.exit(0); |
|||
}); |
|||
d.run(function() { |
|||
setTimeout(function() { |
|||
throw new Error('exceptional!'); |
|||
}, 33); |
|||
}); |
|||
} |
|||
|
|||
function timerPlusNextTick() { |
|||
var domain = require('domain'); |
|||
var d = domain.create(); |
|||
|
|||
d.on('error', function(err) { |
|||
console.log('ok'); |
|||
process.exit(0); |
|||
}); |
|||
d.run(function() { |
|||
setTimeout(function() { |
|||
process.nextTick(function() { |
|||
throw new Error('exceptional!'); |
|||
}); |
|||
}, 33); |
|||
}); |
|||
} |
|||
|
|||
function firstRun() { |
|||
var domain = require('domain'); |
|||
var d = domain.create(); |
|||
|
|||
d.on('error', function(err) { |
|||
console.log('ok'); |
|||
process.exit(0); |
|||
}); |
|||
d.run(function() { |
|||
throw new Error('exceptional!'); |
|||
}); |
|||
} |
|||
|
|||
function netServer() { |
|||
var domain = require('domain'); |
|||
var net = require('net'); |
|||
var d = domain.create(); |
|||
|
|||
d.on('error', function(err) { |
|||
console.log('ok'); |
|||
process.exit(0); |
|||
}); |
|||
d.run(function() { |
|||
var server = net.createServer(function(conn) { |
|||
conn.pipe(conn); |
|||
}); |
|||
server.listen(Number(process.argv[1]), '0.0.0.0', function() { |
|||
var conn = net.connect(Number(process.argv[1]), '0.0.0.0') |
|||
conn.once('data', function() { |
|||
throw new Error('ok'); |
|||
}) |
|||
conn.end('ok'); |
|||
}); |
|||
}); |
|||
} |
Loading…
Reference in new issue