diff --git a/src/node.cc b/src/node.cc index a18e0d89d5c02e..ac906f0cd5c71a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -918,7 +918,7 @@ Handle UsingDomains(const Arguments& args) { Local tdc = tdc_v.As(); Local ndt = ndt_v.As(); process->Set(String::New("_tickCallback"), tdc); - process->Set(String::New("nextTick"), ndt); + process->Set(String::New("_currentTickHandler"), ndt); process_tickCallback.Dispose(); // Possibly already set by MakeCallback(). process_tickCallback = Persistent::New(tdc); return Undefined(); diff --git a/src/node.js b/src/node.js index bdbe1c5e16d215..b54ff51752a9fd 100644 --- a/src/node.js +++ b/src/node.js @@ -331,8 +331,12 @@ var index = 1; var depth = 2; - process.nextTick = nextTick; + process.nextTick = function nextTick(cb) { + process._currentTickHandler(cb); + }; + // needs to be accessible from cc land + process._currentTickHandler = _nextTick; process._nextDomainTick = _nextDomainTick; process._tickCallback = _tickCallback; process._tickDomainCallback = _tickDomainCallback; @@ -472,7 +476,7 @@ tickDone(0); } - function nextTick(callback) { + function _nextTick(callback) { // on the way out, don't bother. it won't get fired anyway. if (process._exiting) return; diff --git a/test/message/max_tick_depth_trace.out b/test/message/max_tick_depth_trace.out index 22184a69119bfc..c9db2c5580a6e3 100644 --- a/test/message/max_tick_depth_trace.out +++ b/test/message/max_tick_depth_trace.out @@ -10,6 +10,7 @@ tick 12 tick 11 Trace: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral. at maxTickWarn (node.js:*:*) + at process._nextTick [as _currentTickHandler] (node.js:*:*) at process.nextTick (node.js:*:*) at f (*test*message*max_tick_depth_trace.js:*:*) at process._tickCallback (node.js:*:*) @@ -28,6 +29,7 @@ tick 2 tick 1 Trace: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral. at maxTickWarn (node.js:*:*) + at process._nextTick [as _currentTickHandler] (node.js:*:*) at process.nextTick (node.js:*:*) at f (*test*message*max_tick_depth_trace.js:*:*) at process._tickCallback (node.js:*:*) diff --git a/test/simple/test-next-tick-domain.js b/test/simple/test-next-tick-domain.js new file mode 100644 index 00000000000000..16f77ed94d5309 --- /dev/null +++ b/test/simple/test-next-tick-domain.js @@ -0,0 +1,29 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); + +var origNextTick = process.nextTick; + +require('domain'); + +assert.strictEqual(origNextTick, process.nextTick, 'Requiring domain should not change nextTick');