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

Commit

Permalink
nextTick: explicitly no-op when _exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 17, 2012
1 parent 4e5fe2d commit 19ecc17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/node.js
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion test/simple/test-next-tick.js
Expand Up @@ -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');
});
});

0 comments on commit 19ecc17

Please sign in to comment.