【ask】Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

1.周五对nodejs tcp长连接服务器框架进行压测,一切开始比较常规(没什么特殊问题)。

2.突然手一哆嗦,把压测用的客户端群一起关闭了。

3.这个时候nodejs的服务器爆出了"Caught exception: Error: read ECONNRESET"。

4.这个以前做linux服务器时候见过(忽略掉SIGPIPE信号,nodejs默认也是这么做的),没有太在意。

5.但是紧接着标题里的错误出现了,一看这个我感觉肯定不是自己直接调用的原因。

6.心想先写一个最简单的服务器,只链接不接包也不发包,然后一起关闭压测用客户端群。看看什么样子。

7.依然出现

 Caught exception: Error: read ECONNRESET
    at errnoException (net.js:904:11)
    at TCP.onread (net.js:558:19)
......(若干条)
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
......(若干条)
node.js:0
// Copyright Joyent, Inc. and other Node contributors.
^
RangeError: Maximum call stack size exceeded
 
8.我想这肯定不是我或者是nodejs本身的问题,可能是有哪没设置好的问题。(linux进程的句柄数默认不也是1024么!需要用ulimit -n设置才行)。
9.想到这里开始在nodejs官方文档里看,是一个一个api的看啊(有点暴力,但是我一开始就是认为这应该是全局的设置问题,所以就是从process这里开始的,所以几分钟内就看到了这个)!
10.试着改了一下,立刻见效了。
11.但是心里仍然有些不踏实,恐怕还是要等搞定cocos2d-x的问题之后有时间,再来看看nodejs这块的源码。

process.maxTickDepth

  • Number Default = 1000

Callbacks passed to process.nextTick will usually be called at the end of the current flow of execution, and are thus approximately as fast as calling a function synchronously. Left unchecked, this would starve the event loop, preventing any I/O from occurring.  

 

posted on 2014-08-11 16:43  南原始天  阅读(481)  评论(0编辑  收藏  举报