Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
process: fix process.nextTick() error case regression
Browse files Browse the repository at this point in the history
Patch and test by Koichi Kobayashi.
  • Loading branch information
bnoordhuis committed Nov 1, 2011
1 parent f5a01d1 commit 362b5a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/node.js
Expand Up @@ -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();
}
Expand Down
23 changes: 23 additions & 0 deletions test/simple/test-process-next-tick.js
@@ -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);
});

0 comments on commit 362b5a6

Please sign in to comment.