From 19ecc17e6b6ed9c883a6cc939f0f3211c6dbc37c Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 16 Jul 2012 11:45:12 -0700 Subject: [PATCH] nextTick: explicitly no-op when _exiting --- src/node.js | 4 ++++ test/simple/test-next-tick.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) 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'); + }); });