我的应用程序在本地和生产方面都无法实现。
当我转到http://localhost:3000/?_escaped_fragment_=
时,我可以看到出现以下错误(幻影在15秒后被杀死):
spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }
似乎很多其他人都遇到了这个问题:
问题是我没有使用天文台或select2,我的所有出版物都返回一个光标。据我说,问题来自缩小。我刚读了in this thread有人成功显示“SyntaxError:Parse error”。我怎么能更多地了解Phantom出了什么问题以及导致问题的文件?
答案 0 :(得分:3)
当spiderable正在等待未能返回任何数据并最终超时的订阅时,会发生这种情况,如您链接的某些线程中所述。
确保所有publish functions要么返回游标,可能是空的游标列表,要么发送this.ready()
。
Meteor APM可能有助于确定哪些出版物没有返回。
答案 1 :(得分:2)
如果您想了解更多关于phatomjs的问题,可以试试code(1):
// Put your URL below, no "?_escaped_fragment_=" necessary
var url = "http://your-url.com/";
var page = require('webpage').create();
page.open(url);
setInterval(function() {
var ready = page.evaluate(function () {
if (typeof Meteor !== 'undefined'
&& typeof(Meteor.status) !== 'undefined'
&& Meteor.status().connected) {
Deps.flush();
return DDP._allSubscriptionsReady();
}
return false;
});
if (ready) {
var out = page.content;
out = out.replace(/<script[^>]+>(.|\n|\r)*?<\/script\s*>/ig, '');
out = out.replace('<meta name=\"fragment\" content=\"!\">', '');
console.log(out);
phantom.exit();
}
}, 100);
要在本地使用,请安装phantomjs。然后在应用外部,使用上面的代码创建一个文件phantomtest.js
。并运行phantomjs phantomtest.js
您可以尝试的另一件事是使用UglifyJS将缩小的JS文件中的一些错误捕获为Payner35 did。
答案 2 :(得分:1)
我的问题来自SSL。 You can have a complete overview of what I did here.
编辑spiderable源并将--ignore-ssl-errors=yes
添加到phantomjs命令行,它将起作用。