简体   繁体   English

找出Heroku应用程序出了什么问题

[英]Figuring out what's wrong with Heroku applications

I just created a web application and i just pushed it to heroku (it is the first time i play around with heroku). 我刚刚创建了一个Web应用程序,然后将其推送到heroku(这是我第一次玩heroku)。

I uploaded just fine and the index page loads, but then i get an error. 我上传得很好,索引页面已加载,但随后出现错误。

My web application consists of rendering a form, then getting the POST data and submitting it to an asynchronous function that spawns puppeteer. 我的Web应用程序包括呈现一个表单,然后获取POST数据,并将其提交给产生伪娘的异步函数。

When the function ends it has two choices. 函数结束时有两个选择。 Running .then() which suggets the function succedeed and prompting the user with a download. 运行表示功能成功的.then(),并提示用户进行下载。

Or running .catch() which means the function failed, and it will render an error page. 或运行.catch()意味着函数失败,它将呈现一个错误页面。

In my local tests, in NEVER fails. 在我的本地测试中,永不失败。 The only way to make it fail, is to close the console (pressing the X button in the GUI). 使其失败的唯一方法是关闭控制台(按GUI中的X按钮)。

In heroku, the page loads, i do the post and i am shown the error page. 在heroku中,页面加载,我进行发布,并向我显示错误页面。 Which means the asynchronous function failed and i get the .catch() portion. 这意味着异步功能失败,我得到了.catch()部分。

So since this function never fails in my local machine, how can i figure out what's wrong? 因此,由于此功能在我的本地计算机上永远不会失败,因此我如何找出问题所在? Is there some debugging that can be done in heroku? 在heroku中可以进行一些调试吗?

Or maybe shall i contact customer suuport. 也许我应该联系客户支持。

I also have to note that this is a free upload. 我还必须注意,这是免费上传。 I am guessing maybe it is a memory issue? 我猜想这可能是内存问题?

EDIT: As user nourza suggested, this is the log by running heroku logs -t and triggering the error: 编辑:如用户nourza建议,这是通过运行heroku logs -t并触发错误的日志:

2018-09-06T20:53:53.094525+00:00 heroku[router]: at=info method=POST path="/sc"
fwd="130.43.124.255" dyno=web.1 connect=0ms service=23ms status=200 bytes=1359 p
rotocol=http
2018-09-06T20:53:53.091659+00:00 app[web.1]: Error: Failed to launch chrome!
2018-09-06T20:53:53.091671+00:00 app[web.1]: /app/node_modules/puppeteer/.local-
chromium/linux-579032/chrome-linux/chrome: error while loading shared libraries:
 libX11-xcb.so.1: cannot open shared object file: No such file or directory
2018-09-06T20:53:53.091674+00:00 app[web.1]:
2018-09-06T20:53:53.091675+00:00 app[web.1]:
2018-09-06T20:53:53.091678+00:00 app[web.1]: TROUBLESHOOTING: https://github.com
/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
2018-09-06T20:53:53.091679+00:00 app[web.1]:
2018-09-06T20:53:53.091681+00:00 app[web.1]: at onClose (/app/node_modules/puppe
teer/lib/Launcher.js:299:14)
2018-09-06T20:53:53.091683+00:00 app[web.1]: at Interface.helper.addEventListene
r (/app/node_modules/puppeteer/lib/Launcher.js:288:50)
2018-09-06T20:53:53.091686+00:00 app[web.1]: at emitNone (events.js:111:20)
2018-09-06T20:53:53.091687+00:00 app[web.1]: at Interface.emit (events.js:208:7)

2018-09-06T20:53:53.091689+00:00 app[web.1]: at Interface.close (readline.js:368
:8)
2018-09-06T20:53:53.091690+00:00 app[web.1]: at Socket.onend (readline.js:147:10
)
2018-09-06T20:53:53.091692+00:00 app[web.1]: at emitNone (events.js:111:20)
2018-09-06T20:53:53.091694+00:00 app[web.1]: at Socket.emit (events.js:208:7)
2018-09-06T20:53:53.091696+00:00 app[web.1]: at endReadableNT (_stream_readable.
js:1064:12)
2018-09-06T20:53:53.091698+00:00 app[web.1]: at _combinedTickCallback (internal/
process/next_tick.js:138:11)
2018-09-06T20:53:53.295994+00:00 heroku[router]: at=info method=GET path="/js/bo
otstrap.min.js" 

EDIT 2: After adding the line for the puppeteer buildpack, as user nourza suggested, it still does not work. 编辑2:在为puppeteer buildpack添加行之后,如nourza用户建议的那样,它仍然不起作用。 This is the new output of heroku logs -t : 这是heroku logs -t的新输出:

2018-09-07T13:16:10.870497+00:00 app[web.1]: Error: Failed to launch chrome!
2018-09-07T13:16:10.870512+00:00 app[web.1]: [0907/131610.045486:FATAL:zygote_ho
st_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chro
mium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.
md for more information on developing with the SUID sandbox. If you want to live
 dangerously and need an immediate workaround, you can try using --no-sandbox.
2018-09-07T13:16:10.870514+00:00 app[web.1]: #0 0x562ae7866dfc base::debug::Stac
kTrace::StackTrace()
2018-09-07T13:16:10.870516+00:00 app[web.1]: #1 0x562ae77e6150 logging::LogMessa
ge::~LogMessage()
2018-09-07T13:16:10.870518+00:00 app[web.1]: #2 0x562ae8c000c0 service_manager::
ZygoteHostImpl::Init()
2018-09-07T13:16:10.870520+00:00 app[web.1]: #3 0x562ae74d1c1e content::ContentM
ainRunnerImpl::Initialize()
2018-09-07T13:16:10.870522+00:00 app[web.1]: #4 0x562ae7506128 service_manager::
Main()
2018-09-07T13:16:10.870524+00:00 app[web.1]: #5 0x562ae74d01a1 content::ContentM
ain()
2018-09-07T13:16:10.870528+00:00 app[web.1]: #6 0x562aeb90be9d headless::(anonym
ous namespace)::RunContentMain()
2018-09-07T13:16:10.870529+00:00 app[web.1]: #7 0x562aeb90bf28 headless::Headles
sBrowserMain()
2018-09-07T13:16:10.870531+00:00 app[web.1]: #8 0x562ae75037fa headless::Headles
sShellMain()
2018-09-07T13:16:10.870533+00:00 app[web.1]: #9 0x562ae59501ac ChromeMain
2018-09-07T13:16:10.870534+00:00 app[web.1]: #10 0x7f54d8f09830 __libc_start_mai
n
2018-09-07T13:16:10.870536+00:00 app[web.1]: #11 0x562ae595002a _start
2018-09-07T13:16:10.870538+00:00 app[web.1]:
2018-09-07T13:16:10.870540+00:00 app[web.1]: Received signal 6
2018-09-07T13:16:10.870541+00:00 app[web.1]: #0 0x562ae7866dfc base::debug::Stac
kTrace::StackTrace()
2018-09-07T13:16:10.870543+00:00 app[web.1]: #1 0x562ae7866961 base::debug::(ano
nymous namespace)::StackDumpSignalHandler()
2018-09-07T13:16:10.870544+00:00 app[web.1]: #2 0x7f54dee52390 <unknown>
2018-09-07T13:16:10.870546+00:00 app[web.1]: #3 0x7f54d8f1e428 gsignal
2018-09-07T13:16:10.870548+00:00 app[web.1]: #4 0x7f54d8f2002a abort
2018-09-07T13:16:10.870549+00:00 app[web.1]: #5 0x562ae78657b5 base::debug::Brea
kDebugger()
2018-09-07T13:16:10.870551+00:00 app[web.1]: #6 0x562ae77e65b9 logging::LogMessa
ge::~LogMessage()
2018-09-07T13:16:10.870553+00:00 app[web.1]: #7 0x562ae8c000c0 service_manager::
ZygoteHostImpl::Init()
2018-09-07T13:16:10.870554+00:00 app[web.1]: #8 0x562ae74d1c1e content::ContentM
ainRunnerImpl::Initialize()
2018-09-07T13:16:10.870556+00:00 app[web.1]: #9 0x562ae7506128 service_manager::
Main()
2018-09-07T13:16:10.870557+00:00 app[web.1]: #10 0x562ae74d01a1 content::Content
Main()
2018-09-07T13:16:10.870559+00:00 app[web.1]: #11 0x562aeb90be9d headless::(anony
mous namespace)::RunContentMain()
2018-09-07T13:16:10.870561+00:00 app[web.1]: #12 0x562aeb90bf28 headless::Headle
ssBrowserMain()
2018-09-07T13:16:10.870563+00:00 app[web.1]: #13 0x562ae75037fa headless::Headle
ssShellMain()
2018-09-07T13:16:10.870564+00:00 app[web.1]: #14 0x562ae59501ac ChromeMain
2018-09-07T13:16:10.870566+00:00 app[web.1]: #15 0x7f54d8f09830 __libc_start_mai
n
2018-09-07T13:16:10.870568+00:00 app[web.1]: #16 0x562ae595002a _start
2018-09-07T13:16:10.870570+00:00 app[web.1]: r8: 00007f54d92af770  r9: 00007f54d
f3cfac0 r10: 0000000000000008 r11: 0000000000000206
2018-09-07T13:16:10.870572+00:00 app[web.1]: r12: 00007ffc93c4acd8 r13: 00000000
00000161 r14: 00007ffc93c4ace0 r15: 00007ffc93c4ace8
2018-09-07T13:16:10.870574+00:00 app[web.1]: di: 0000000000000017  si: 000000000
0000017  bp: 00007ffc93c4a820  bx: 00007ffc93c4a890
2018-09-07T13:16:10.870575+00:00 app[web.1]: dx: 0000000000000006  ax: 000000000
0000000  cx: 00007f54d8f1e428  sp: 00007ffc93c4a6e8
2018-09-07T13:16:10.870577+00:00 app[web.1]: ip: 00007f54d8f1e428 efl: 000000000
0000206 cgf: 0000000000000033 erf: 0000000000000000
2018-09-07T13:16:10.870579+00:00 app[web.1]: trp: 0000000000000000 msk: 00000000
00000000 cr2: 0000000000000000
2018-09-07T13:16:10.870581+00:00 app[web.1]: [end of stack trace]
2018-09-07T13:16:10.870582+00:00 app[web.1]: Calling _exit(1). Core file will no
t be generated.
2018-09-07T13:16:10.870584+00:00 app[web.1]:
2018-09-07T13:16:10.870586+00:00 app[web.1]:
2018-09-07T13:16:10.870587+00:00 app[web.1]: TROUBLESHOOTING: https://github.com
/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
2018-09-07T13:16:10.870589+00:00 app[web.1]:
2018-09-07T13:16:10.870590+00:00 app[web.1]: at onClose (/app/node_modules/puppe
teer/lib/Launcher.js:299:14)
2018-09-07T13:16:10.870592+00:00 app[web.1]: at Interface.helper.addEventListene
r (/app/node_modules/puppeteer/lib/Launcher.js:288:50)
2018-09-07T13:16:10.870594+00:00 app[web.1]: at emitNone (events.js:111:20)
2018-09-07T13:16:10.870596+00:00 app[web.1]: at Interface.emit (events.js:208:7)

2018-09-07T13:16:10.870597+00:00 app[web.1]: at Interface.close (readline.js:368
:8)
2018-09-07T13:16:10.870599+00:00 app[web.1]: at Socket.onend (readline.js:147:10
)
2018-09-07T13:16:10.870601+00:00 app[web.1]: at emitNone (events.js:111:20)
2018-09-07T13:16:10.870602+00:00 app[web.1]: at Socket.emit (events.js:208:7)
2018-09-07T13:16:10.870604+00:00 app[web.1]: at endReadableNT (_stream_readable.
js:1064:12)
2018-09-07T13:16:10.870606+00:00 app[web.1]: at _combinedTickCallback (internal/
process/next_tick.js:138:11)
2018-09-07T13:16:11.090206+00:00 heroku[router]: at=info method=GET path="/style
sheets/bootstrap.min.css" host=insta-ripper.herokuapp.com request_id=dff59a00-35
6d-49f4-a171-657856e671b9 fwd="130.43.124.255" dyno=web.1 connect=0ms service=17
ms status=304 bytes=239 protocol=http
2018-09-07T13:16:11.096037+00:00 heroku[router]: at=info method=GET path="/js/bo
otstrap.min.js" host=insta-ripper.herokuapp.com request_id=9cf76ded-1405-40c7-87
71-70fa342b37e3 fwd="130.43.124.255" dyno=web.1 connect=0ms service=17ms status=
404 bytes=402 protocol=http
2018-09-07T13:16:11.321014+00:00 heroku[router]: at=info method=GET path="/js/bo
otstrap.min.js" host=insta-ripper.herokuapp.com request_id=98d04e8d-2dbb-4546-89
e4-a6ae47c85831 fwd="130.43.124.255" dyno=web.1 connect=0ms service=8ms status=4
04 bytes=402 protocol=http

After following user nourza's advice (which i cannot thank enough) and adding the options: 在遵循了用户nourza的建议(对此我感激不尽)并添加了选项之后:

['--no-sandbox', '--disable-setuid-sandbox'] in the puppeteer.launch() function, the app manages to run, but at some time this is rendered: ['--no-sandbox', '--disable-setuid-sandbox']puppeteer.launch()函数中,该应用程序设法运行,但在某些时候呈现:

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail

So i run heroku logs --tail , and the only thing suspicious is this: 所以我运行heroku logs --tail ,唯一可疑的是:

2018-09-07T17:47:27.555737+00:00 heroku[router]: at=error code=H12 desc="Request
 timeout" method=POST path="/sc" request_id=21e8b890-4072-426e-bac3-91c3646a0301 fwd="130.43.124.255" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=http

The server seems to break down at this code: 服务器似乎在以下代码处崩溃:

var fileContents = Buffer.from(result, 'ascii');
var readStream = new stream.PassThrough();
readStream.end(fileContents);
res.set('Content-disposition', 'attachment; filename=' + fileName);
res.set('Content-Type', 'text/plain');
readStream.pipe(res);

Which is a way to make the user download a part of memory as a .txt file. 这是使用户下载一部分内存作为.txt文件的方法。

Check this link Error while excuting chrome without headless on heroku 检查此链接在Heroku上执行无头的chrome时出错

You need to include the Puppeteer Heroku buildpack to the list of buildpacks for your app. 您需要将Puppeteer Heroku构建包包括在您的应用程序的构建包列表中。 Go to your Heroku dashboard and open your app. 转到您的Heroku仪表板并打开您的应用程序。 Go to Settings > Buildpacks > Add buildpack and use this URL. 转到设置>构建包>添加构建包,然后使用此URL。

https://github.com/jontewks/puppeteer-heroku-buildpack When you click add buildpack, simply paste that URL into the input, and click save. https://github.com/jontewks/puppeteer-heroku-buildpack单击添加构建包时,只需将该URL粘贴到输入中,然后单击保存。 On the next deploy, your app will also install the dependencies that Puppeteer needs to run. 在下一次部署中,您的应用程序还将安装Puppeteer需要运行的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM