Puppeteer 无法在 heroku 上运行
问题描述:
我在 heroku 上部署了一个应用程序,并添加了 puppeteer Heroku buildpack.
I deployed an app on heroku, and i added the puppeteer Heroku buildpack.
成功重新部署后,我尝试运行它,但它失败了.使用 heroku logs -t
,我收到此错误消息:
After a succesful redeployment, i try to run it and it fails. Using heroku logs -t
, i get this error message:
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.
答
您应该能够通过传递 --no-sandbox
和 --disable-setuid-sandbox
标志切换到 puppeteer.launch()
:
You should be able to solve this issue by passing the --no-sandbox
and --disable-setuid-sandbox
flags to puppeteer.launch()
:
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
],
});
如果这不起作用,您可能需要阅读官方 Puppeteer 故障排除指南:在 Heroku 上运行 Puppeteer.
If this does not work, you may want to read the official Puppeteer troubleshooting guide: Running Puppeteer on Heroku.