【问题标题】:warning: Recursive process.nextTick detected警告:检测到递归 process.nextTick
【发布时间】:2014-05-03 21:27:04
【问题描述】:

我有应用程序,我开始使用它,我只想运行它,但它崩溃了。它使用运行节点服务器的 grunt,它是 Angular.js 应用程序。当我运行运行服务器的 grunt 任务并且尝试从浏览器访问应用程序时,我收到了来自 grunt 或节点的警告:

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

很多行,最后:

util.js:35
  var str = String(f).replace(formatRegExp, function(x) {
                      ^
RangeError: Maximum call stack size exceeded Use --force to continue.

    Aborted due to warnings.

我尝试在我的应用程序中搜索process.nextTick,但它在node_modules 目录中的很多地方,而不是在src 中。

是否可以删除该警告以便我可以运行应用程序?我应该搜索什么代码来搜索这个递归调用?

更新

我使用ack,发现这行来自这个文件的3个地方:

$REPO/node_modules/express/node_modules/connect/node_modules/multiparty/node_modules/‌​readable- stream/node_modules/core-util-is/float.patch
$REPO/node_modules/grunt-browser-sync/node_modules/browser-sync/node_modules/connect/‌​node_modu les/multiparty/node_modules/readable-stream/node_modules/core-util-is/float.patc‌​h 
/usr/lib/node_modules/bower/node_modules/decompress-zip/node_modules/readable-s‌​tream/nod e_modules/core-util-is/float.patch

但不是js文件。

【问题讨论】:

标签: javascript node.js recursion gruntjs


【解决方案1】:

就我而言,在引发此错误之前我收到了以下警告:

Running "watch" task
Waiting...
Warning: watch ENOSPC

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

此错误表明它尝试观看的资源数量高于此用户的限制。这就是为什么以 root 用户身份运行(没有这些限制)可以正常工作的原因。但这不是解决方案。

找出你的用户在 Linux 中的限制:

sysctl --all | grep watches

尝试增加当前用户的观看次数:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

这应该可以解决问题。

【讨论】:

    【解决方案2】:

    正如我在这里发布的:grunt throw "Recursive process.nextTick detected"

    替代解决方案:检查手表是否存在空文件参数

    这是我gruntfile的摘录

    watch: {
      all: {
        options:{
          livereload: true
        },
        files: ['src/scss/*.scss', 'src/foo.html',, 'src/bar.html'],
        tasks: ['default']
      }
    }
    

    就我而言,我可以使用上面的空参数按需重新创建原始海报的错误。

    【讨论】:

      【解决方案3】:

      npm dedupe 为我解决了这个问题。基本上它减少了包重复:

      搜索本地包树并尝试通过将依赖关系进一步向上移动来简化整体结构,从而可以更有效地由多个依赖包共享。

      More information

      【讨论】:

        【解决方案4】:

        这可能是个棘手的问题。如果您的命名约定中有重复,Grunt 会呕吐。

        这将打破:

        grunt.registerTask('foo', [ 'foo']);
        

        这不会:

        grunt.registerTask('foo', [ 'bar']);
        

        查看这篇 SO 帖子:grunt throw "Recursive process.nextTick detected"

        【讨论】:

        • 找到了原因,这是因为资源限制(我认为是因为堆栈大小)。我的帐户有限制,我什至不知道 Linux 上有限制。当我从 root 运行应用程序时,它工作正常。
        • @AlexanderBurakevych 我已经在 Linux 上使用sudo 运行了该应用程序,它可以正常工作。
        • @jcubic 核心问题(至少在我的情况下)是 user_watches 的数量有限:fs.inotify.max_user_watches。一旦设置为更高的数字 - 它工作正常。我猜 sudo 用户没有这个限制。 stackoverflow.com/questions/16748737/…
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-12
        • 1970-01-01
        • 1970-01-01
        • 2014-03-02
        相关资源
        最近更新 更多