我使用express和sulla(导入puppeteer)作为核心 Node 构建了一个应用程序。
基本上,我抓取一些数据并使用 sulla 通过 Whatsapp 发送它们。 它在本地运行良好,但是当我将其部署在 heroku 上时,我遇到了这个问题:
Failed to launch the browser process!\n[0601/222716.792459:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.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 ...... Core file will not be generated.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
我已经将以下构建包添加到我的 heroku 应用程序中:
https://github.com/jontewks/puppeteer-heroku-buildpack.git
heroku/nodejs
https://github.com/heroku/heroku-buildpack-chromedriver
我见过类似 https://stackoverflow.com/a/52228855 的解决方案,但我无法应用它,因为我不直接使用 puppeteer。或者清除heroku缓存但没有成功。
最佳答案
不幸的是,除非您使用 sulla 的当前 npm 包,否则它无法在 Heroku 上工作。正如链接的问题所述,您需要使用 --no- 启动 puppeteer沙箱
(--disable-setuid-sandbox arg对于Heroku来说不是强制性的):
await puppeteer.launch({ args: ['--no-sandbox'] })
Sulla 在 npm 包中缺少此参数 ( launch ) ( current launch config ) ( not used launch config that would work with Heroku )。
非常好,您已经添加了构建包,如果 puppeteer 在后台作为依赖项运行,则需要这些构建包。
I.) 你可以尝试一个 sulla 的分支,名为 sulla-hotfix: https://www.npmjs.com/package/@jprustv/sulla-hotfix如果它适合您的需求。这个still uses previous sulla puppeteer config ,其中显然包含 --no-sandbox
launch arg。
对于原始项目 sulla 来说,确实是从:@open-wa/wa-automate fork 出来的。 。它可能适用于具有构建包的 Heroku。
II.) 或者您可以根据 MIT 许可发布 sulla 的修改版本,其中包含正确的启动参数。
关于node.js - 无法在 Heroku 上启动浏览器进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62142249/