node.js - Puppeteer - UnhandledPromiseRejectionWarning
问题描述
我尝试使用木偶师,
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://10.1.40.117/print/d37a2017-4bc4-46fb-9a8a-7ddc31e65a33', {waitUntil: 'networkidle2'});
await page.pdf({path: 'hn.pdf', format: 'A4'});
await browser.close();
})();
收到以下错误,
(node:16064) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: net::ERR_CERT_AUTHORITY_INVALID at https://10.1.40.117/print/d37a2017-4bc4-46fb-9a8a-7ddc31e65a33
(node:16064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
对此有什么帮助吗?
解决方案
ignoreHTTPSErrors: true
启动浏览器实例时尝试。当您在本地使用自签名证书时会发生这种情况。
解决方案:
const browser = await puppeteer.launch({ignoreHTTPSErrors: true});
推荐阅读
- apache-kafka - kafka中如何让一个消费者离开并进入一个消费组
- c++ - 在带有 std::greater 附加参数的 std::map 上使用三元运算符
- xml - Dataweave - 循环深度映射 XML
- php - PHPUnit - 断言两个字符串相等失败
- sql - 如何在存储过程之外调用表变量
- reactjs - 在 ReactJS 中用组件替换字符串
- powershell - PowerShell 列表组合器 - 请优化
- c++ - 共享对象中的符号名称不同于 .cpp 文件中的函数
- react-native - 如何解决 react-native 中的“未定义不是函数(评估'UIManagerConfig('RSSSignatureView')')”错误
- laravel - Laravel:试图在雄辩的关系上获取非对象错误的属性