在Heroku上出错。无法启动Chrome

时间:2019-12-06 16:28:57

标签: node.js heroku puppeteer

2019-12-06T16:09:57.053282+00:00 app[web.1]: Error: Failed to launch chrome!
2019-12-06T16:09:57.053298+00:00 app[web.1]:
2019-12-06T16:09:57.053301+00:00 app[web.1]: (chrome:44): Gtk-WARNING **: 16:09:57.031: cannot open display:
2019-12-06T16:09:57.053303+00:00 app[web.1]:
2019-12-06T16:09:57.053305+00:00 app[web.1]:
2019-12-06T16:09:57.053308+00:00 app[web.1]: TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
2019-12-06T16:09:57.053310+00:00 app[web.1]:
2019-12-06T16:09:57.053312+00:00 app[web.1]: at onClose (/app/node_modules/puppeteer/lib/Launcher.js:348:14)
2019-12-06T16:09:57.053314+00:00 app[web.1]: at ChildProcess. (/app/node_modules/puppeteer/lib/Launcher.js:338:60)
2019-12-06T16:09:57.053317+00:00 app[web.1]: at ChildProcess.emit (events.js:215:7)
2019-12-06T16:09:57.053319+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
2019-12-06T16:10:26.921203+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/product/new?search=https%3A%2F%2Fwww.walmart.com%2Fip%2FHamilton-Beach-Set-n-Forget-6-Quart-Slow-Cooker-Model-33969%2F16913518" host=arcane-wave-04024.herokuapp.com request_id=34a979c5-a553-4ba2-b233-af91b577d74a fwd="124.29.252.211" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https

我收到此错误。我已经设置了以下内容: puppeteer.launch({args:['--no-sandbox']});

已添加:https://github.com/jontewks/puppeteer-heroku-buildpack 到构建包。

有人可以帮我这个忙吗?代码在本地主机上运行良好。但是当我在heroku上部署它时,它会不断出现此错误。

1 个答案:

答案 0 :(得分:0)

我在操纵p和Heroku时遇到了同样的问题。我安装了您提到的同一构建包,并使用了以下代码,现在可以正常使用了。

puppeteer.launch({ 无头:是的, args:['--no-sandbox','--disable-setuid-sandbox'] })

我在安装构建包后再次部署了PS。