当我使用 Node 8 在 Cloud Functions 上运行 Puppeteer 时,出现此错误。
Error: Failed to launch chrome!
[1205/063825.588245:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Run Code Online (Sandbox Code Playgroud)
启动 Puppeteer
browser = await puppeteer.launch({
args: ['--no-sandbox'],
headless: true
})
Run Code Online (Sandbox Code Playgroud)
解决了这个问题。我在互联网上搜索过,但找不到任何必要的理由?
为什么 Headless Chrome 首先以 root 身份运行?
node.js firebase google-cloud-functions google-chrome-headless puppeteer
我正在使用ESLint并且我收到此错误:每个then()都应该返回一个值或抛出promise/always-return
码:
return somePromise.then(result => {
console.log(result);
}).catch(error => {
console.error(error);
});
Run Code Online (Sandbox Code Playgroud)
我为什么要从这个承诺中回来?显然没有必要,因为我只想在日志中打印结果,就是这样.在所有情况下都适用这条规则似乎不对.我正在写一个Firebase数据库触发器,我相信它只对知道承诺是否已经解决感兴趣.