Is there a way to avoid this error: (node) warning: Recursive process.nextTick detected

北城以北 提交于 2020-01-07 06:57:21

问题


I'm seeing a bunch of questions around this error but no one seems to have an actual answer and none of the causes listed by the other posters apply to my case.

I've tracked it down to happening when I upload a particularly large file (50mb or more) from my server over to Amazon's S3. Somewhere in that process I get several hundred instances of

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

and then eventually a

var str = String(f).replace(formatRegExp, function(x) {
                      ^
RangeError: Maximum call stack size exceeded

Curious if anyone else has seen this specific instance and managed to find a solution. I'll obviously post one as an answer if I figure it out.


回答1:


To actually fix this you must

  1. Identify the line of code that is causing this.
    • search for process.nextTick in both your code and your npm dependencies
    • OR If you can reproduce in the debugger and set a break point at the code in node core that throws that error, you may be able to look at the stack at that point and identify the root cause file/line.
  2. Change that code to use setImmediate instead
    • It is not necessarily your app code that is the root cause, so you may need to fork/PR a third party module


来源:https://stackoverflow.com/questions/32187065/is-there-a-way-to-avoid-this-error-node-warning-recursive-process-nexttick-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!