process: fix process.nextTick() error case regression

Patch and test by Koichi Kobayashi.
This commit is contained in:
Ben Noordhuis 2011-11-01 16:30:41 +01:00
parent f5a01d1764
commit 362b5a6c40
2 changed files with 26 additions and 0 deletions

View File

@ -192,6 +192,9 @@
for (var i = 0; i < l; i++) q[i]();
}
catch (e) {
if (i + 1 < l) {
nextTickQueue = q.slice(i + 1).concat(nextTickQueue);
}
if (nextTickQueue.length) {
process._needTickCallback();
}

View File

@ -0,0 +1,23 @@
var assert = require('assert');
var N = 2;
var tickCount = 0;
var exceptionCount = 0;
function cb() {
++tickCount;
throw new Error();
}
for (var i = 0; i < N; ++i) {
process.nextTick(cb);
}
process.on('uncaughtException', function() {
++exceptionCount;
});
process.on('exit', function() {
process.removeAllListeners('uncaughtException');
assert.equal(tickCount, N);
assert.equal(exceptionCount, N);
});