[英]Meteor.js Spiderable and Iron Router - fiber error on production server
I'm having trouble getting Iron Router and Spiderable working together nicely in my Meteor.js app. 我在使用Iron Router和Spiderable在我的Meteor.js应用程序中很好地协同工作时遇到了麻烦。 If I test a url with ?_escaped_fragment_=
whilst running on my localhost it all works correctly but as soon as i push to our DigitalOcean production server i keep getting the following error when trying the same thing (check out http://hreglobal.com/?_escaped_fragment_= ): 如果我在本地主机上运行时测试了一个带有?_escaped_fragment_=
的网址,那么一切正常,但是当我推送到我们的DigitalOcean生产服务器时,我在尝试同样的事情时会一直收到以下错误(请访问http://hreglobal.com /?_ escaped_fragment_ = ):
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9)
at _.extend.get (packages/meteor/dynamics_nodejs.js:21)
at RouteController.lookupOption (packages/iron:router/lib/route_controller.js:66)
at new Controller.extend.constructor (packages/iron:router/lib/route_controller.js:26)
at ctor (packages/iron:core/lib/iron_core.js:88)
at Function.Route.createController (packages/iron:router/lib/route.js:133)
at Function.Router.createController (packages/iron:router/lib/router.js:185)
at Function.Router.dispatch (packages/iron:router/lib/router_server.js:39)
at Object.router (packages/iron:router/lib/router.js:15)
at next (/opt/hre/bundle/programs/server/npm/webapp/node_modules/connect/lib/proto.js:190:15)
Have been trying to find the cause for days now and starting to get a bit desperate. 一直试图找到原因几天,并开始有点绝望。 Any pointers welcome! 欢迎任何指示!
There are a few causes for this: 这有几个原因:
When this happens on production but not locally this could mean a package has a minification problem. 当这种情况发生在生产而非本地时,这可能意味着包装有缩小问题。 To test this you can run meteor build --debug which skips minification and deploy. 要测试这个,你可以运行meteor build --debug,它会跳过缩小和部署。 Or you can run locally with meteor run --production which will run it locally with minification. 或者你可以在本地运行meteor run --production,它会在缩小时在本地运行。 Either way should show you if it's a minification problem. 无论哪种方式都应该告诉你它是否是一个缩小问题。
Another option for production issues but not local issues is a timeout issue with spiderable. 生产问题但不是本地问题的另一个选择是spiderable的超时问题。 It may be worth increasing the timeout to see if that solves the problem. 可能值得增加超时以查看是否可以解决问题。 I would try the minification first though. 我会首先尝试缩小。
The third production issue but not local issue has to do with the ROOT_URL being wrong. 第三个生产问题但不是本地问题与ROOT_URL错误有关。 This is also worth checking quickly. 这也值得快速检查。 Make sure that the ROOT_URL that your server is configured to use is accessible by the server itself. 确保服务器本身可以访问服务器配置使用的ROOT_URL。
If this is happening both locally and on a production server, that can be caused by publish calls that do not properly return ready(). 如果在本地和生产服务器上发生这种情况,则可能是由于未正确返回ready()的发布调用引起的。 This can be debugged by commenting out subscriptions on the faulty endpoint until you find the faulty publish. 这可以通过在故障端点上注释掉订阅来调试,直到找到错误的发布。
Is phantomjs installed/accessible to the script on the remote host? 是否在远程主机上的脚本上安装/访问了phantomjs?
I installed a more sophisticated spiderable package: 我安装了一个更复杂的spiderable包:
https://atmospherejs.com/jazeee/spiderable-longer-timeout https://atmospherejs.com/jazeee/spiderable-longer-timeout
that showed me an actual error message instead of irrelevant Error: Meteor code must always run within a Fiber.
这向我展示了一条实际的错误消息而不是无关Error: Meteor code must always run within a Fiber.
The error code appeared to be: 错误代码似乎是:
spiderable: phantomjs not installed. Download and install from http://phantomjs.org/
Things started to work immediately after: 事情开始后立即开始起作用:
sudo apt-get install phantomjs
Jut in case this helps anyone in the future... 如果这有助于将来的任何人......
I was experiencing this issue as well. 我也遇到了这个问题。 I tried everything I could think of and everything all other forums suggested. 我尝试了我能想到的一切以及所有其他论坛建议的一切。
The fix for me was my server! 对我的修复是我的服务器! I have a t2.nano with AWS EC2 and I had uploaded my apps with mup. 我有一个使用AWS EC2的t2.nano,我已经用mup上传了我的应用程序。
It took me a long time to realise this was the cause... but if I just have 2 apps running everything works ok. 我花了很长时间才意识到这是原因......但如果我只有2个应用程序运行,一切正常。 I then added a third app and this is when problems occurred. 然后我添加了第三个应用程序,这是出现问题的时候。 I'm guessing it is down to the basic server I was running not being able to handle 3 docker containers for my apps and a fourth for mongo. 我猜这是由我运行的基本服务器无法处理我的应用程序的3个docker容器和mongo的第四个。
I always had issues uploading my third app with mup as well. 我也总是在使用mup上传我的第三个应用程序时遇到问题。 I'm guessing this might be part of the issue. 我猜这可能是问题的一部分。
So the point is... your publications etc might all be ok but the time to get a response from the server itself rather than the app can have an affect on this too. 所以关键是......你的出版物等可能都可以,但是从服务器本身而不是应用程序获得响应的时间也会对此产生影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.