追踪流星/节点光纤中的堆栈溢出 [英] Tracking down stack overflow in meteor/node fiber

查看:55
本文介绍了追踪流星/节点光纤中的堆栈溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在看到这个崩溃,对节点光纤基础设施不够熟悉,不知道从哪里开始解释错误或检测代码......

I'm seeing this crash now and am not familiar enough with the node fiber infrastructure to know where to begin interpreting the error or instrumenting the code...

Meteor server running on: http://localhost:3000/
W202407-10:06:05.740(-8)? (STDERR) /Users/dauser/.meteor/tools/0b2f28e18b/lib/node_modules/fibers/future.js:173
W202407-10:06:07.363(-8)? (STDERR)                      throw(ex);
W202407-10:06:07.363(-8)? (STDERR)                            ^
W202407-10:06:07.363(-8)? (STDERR) RangeError: Maximum call stack size exceeded
=> Exited with code: 8
=> Meteor server restarted

据我所知,某些事情反复出现有点过于热情,服务器堆栈炸毁,然后崩溃.不幸的是,我不知道这个有问题的函数在哪里——我查看了我的 Deps.autorun 调用(目前只有一个),它似乎不是问题.我的代码都没有使用显式递归实现,而且我没有任何理由怀疑正在传递大对象.显然,我当然不确定.

As I understand it, something is recurring a little too enthusiastically, the server stack blows up, and it crashes. Unfortunately, I have no real idea where this offending function is--I looked at the my Deps.autorun call (just one at the moment) and it does not seem to be the trouble. None of my code is implemented with explicit recursion, and I don't have any reason to suspect large objects are being passed around. Obviously, I'm not really sure, of course.

我真的只是在寻找有关如何检测代码以向我展示事情失控的地方的建议.由于 Meteor 在幕后做了很多工作,如果有人能给我一些关于在哪里查看的指示,那将非常有用.

I'm really just looking for advice on how to instrument the code to show me where things are getting out of hand. Since Meteor's doing a whole lot behind the scenes, it would be really useful if anyone could give me a few pointers as to where to look.

刚刚回到这个,我仍然很迷茫,不知道该往哪里看.this 建议更新到节点 0.11.x 会给我更多信息,但做崩溃时似乎没有添加更多细节.

Just coming back to this, and am still pretty lost as to where to be looking. this suggested updating to node 0.11.x would give me more info, but doing that doesn't seem to have added any more detail when it crashes.

崩溃发生在任何页面交互之后——也就是说,服务器启动并且运行正常,但是如果我在浏览器中重新加载或与页面本身交互,BOOM!

The crash happens after any page interaction--that is, the server starts up and is functioning ok, but if I reload in the browser or interact with the page itself, BOOM!

根据大众需求,这里是服务器代码:

By popular demand, here is the server code:

isAuthorized = () ->
    console.log "checking authorization"
    this.userId == Assets.getText('authorizedUsers')

Meteor.methods(
    isAuthorized : isAuthorized
    filePickerKey : () -> 
        # TODO: properly abstract this, rather than copy/paste...       
        if this.userId == Assets.getText('authorizedUsers')
            Assets.getText('fpKey')
        else
            Meteor.Error 403, 'Error 403: Forbidden')

取消注释 future.js 的第 172 行没有提供更多细节:

uncommenting line 172 of future.js did not provide more details:

I2041-15:52:07.363(-8)? Resolve cb threw Maximum call stack size exceeded

而且,这是我在尝试使用节点检查器时遇到的麻烦.过去半个小时我一直在玩这个,所以我可能只是犯了一些基本错误,但是:我通过 npm (npm install -g node-inspector) 安装了 node-inspector.

And, here's the trouble I run into while trying to use node-inspector. I have been playing with this for the past half hour, so I'm likely just making some fundamental error, but: I installed node-inspector via npm (npm install -g node-inspector).

那我试试

$ node-inspector &
[1] 3408
$ Node Inspector v0.6.2
  info  - socket.io started
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

$ meteor &
[2] 3413
$ [[[[[ ~/Projects/indefinite-ways ]]]]]

=> Meteor server running on: http://localhost:3000/

$ kill -s USR1 3413
Hit SIGUSR1 - starting debugger agent.
debugger listening on port 5858

到目前为止,一切都很好.此时,客户端未在我的浏览器中打开(即没有指向 localhost:3000 的选项卡).我打开一个指向 localhost:5858 的 Chrome 标签页,并查看meteor.js 的源代码我在meteor.js 的第6 行设置了一个断点

so far, so good. At this point, the client side is not open in my browser (i.e. no tab pointing at localhost:3000). I open up a Chrome tab pointing to localhost:5858, and see the source for meteor.js I set a breakpoint on line 6 of meteor.js

var Fiber = require('fibers');

然后打开流星客户端选项卡(本地主机:3000),上述堆栈溢出再次弹出.调试器不会在第 6 行停止,或者以任何其他方式表明它已经注意到.如果我在第 3 行设置断点也是如此.

and then open the meteor client tab (localhost:3000) and the aforementioned stack overflow pops up again. The debugger does not halt on line 6, or in any other way indicate that it has noticed. Same is true if I set a breakpoint at line 3.

推荐答案

稍微更有帮助的答案来自 非官方 Meteor 常见问题解答:

The slightly more helpful answer comes from the unofficial Meteor FAQ:

$ node-inspector &
$ NODE_OPTIONS='--debug-brk' mrt run &

这会在后台启动节点检查器进程,然后启动meteor 的节点容器,并设置正确的调试标志.打开 Chrome 标签以 http://127.0.0.1:8080/debug?port=5858 让我逐步完成.

This starts the node-inspector process in the background, and then starts meteor's node container listening with the right debugging flags set. Opening the Chrome tab to http://127.0.0.1:8080/debug?port=5858 let me step through.

此外,严格来说不是问题的答案,但上面代码中的违规行似乎是在服务器代码中调用 Meteor.Error.我仍然很乐意接受可以确定这一点的答案.我猜 Meteor.Error 根本不是 EJSONable,并且在尝试解析它时,堆栈爆炸了.

Also, not strictly the answer to the question, but the offending line in the code above seems to be calling Meteor.Error in the server code. I'll still gladly accept an answer to this that would have identified that. I'm guessing that Meteor.Error is not at all EJSONable, and in attempting to parse it, the stack explodes.

这篇关于追踪流星/节点光纤中的堆栈溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆