diff --git a/src/node.js b/src/node.js index a86d7230292..b83b890934c 100644 --- a/src/node.js +++ b/src/node.js @@ -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); diff --git a/test/simple/test-next-tick.js b/test/simple/test-next-tick.js index 894729cc6fe..2e40658c923 100644 --- a/test/simple/test-next-tick.js +++ b/test/simple/test-next-tick.js @@ -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'); + }); });