nextTick: explicitly no-op when _exiting

pull/24503/head
isaacs 2012-07-16 11:45:12 -07:00
parent 4e5fe2d45a
commit 19ecc17e6b
2 changed files with 7 additions and 1 deletions

View File

@ -309,6 +309,10 @@
};
process.nextTick = function(callback) {
// on the way out, don't bother.
// it won't get fired anyway.
if (process._exiting) return;
var tock = { callback: callback };
if (process.domain) tock.domain = process.domain;
nextTickQueue.push(tock);

View File

@ -44,7 +44,9 @@ process.nextTick(function() {
complete++;
});
process.on('exit', function() {
assert.equal(5, complete);
process.nextTick(function() {
throw new Error('this should not occur');
});
});