我现在看到了这个崩溃,并且对节点光纤基础设施不够熟悉,不知道从哪里开始解释错误或检测代码......
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 调用(目前只有一个),它似乎不是问题。我的代码都不是通过显式递归实现的,而且我没有任何理由怀疑正在传递大对象。显然,我不太确定。
我实际上只是在寻求有关如何检测代码的建议,以向我展示事情在哪里失控。由于 Meteor 在幕后做了很多工作,如果有人能给我一些关于在哪里查看的指示,那将非常有用。
刚刚回到这个话题,我仍然很迷茫,不知道该去哪里寻找。this https://stackoverflow.com/questions/7663957/debugging-maximum-call-stack-size-exceeded建议更新到节点 0.11.x 会给我更多信息,但这样做似乎并没有在崩溃时添加任何更多细节。
崩溃发生在任何页面交互之后——也就是说,服务器启动并且运行正常,但是如果我在浏览器中重新加载或与页面本身交互,BOOM!
应大众要求,服务器代码如下:
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行的注释没有提供更多细节:
I2041-15:52:07.363(-8)? Resolve cb threw Maximum call stack size exceeded
而且,这是我在尝试使用节点检查器时遇到的麻烦。在过去的半个小时里我一直在玩这个,所以我可能只是犯了一些根本性的错误,但是:
我通过 npm 安装了 node-inspector (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 行设置了一个断点
var Fiber = require('fibers');
然后打开流星客户端选项卡(localhost:3000),再次弹出上述堆栈溢出。调试器不会在第 6 行停止,或以任何其他方式表明它已注意到。如果我在第 3 行设置断点,情况也是如此。