google-chrome - 从 Puppeteer 启动 Chromium 在某台机器上超时 - TimeoutError: waiting for target failed: timeout 30000ms exceeded
问题描述
运行 Puppeteer 并启动 Chromium 时出现以下错误。此外,Chromium 作为崩溃页面打开。我无法从打开的窗口导航到任何 URL。
令人惊讶的是,我仅在从某台机器(在我的公司网络中)运行时才会收到此错误。当从我公司网络中的另一台机器以及我的笔记本电脑上运行时,它运行良好。
环顾四周,我注意到建议添加ignoreDefaultArgs: [ '--disable-extensions' ] }
到配置中,我这样做了,但仍然收到相同的错误。你对我所缺少的有什么建议吗?
错误信息如下
LOG >> -- START PUPPY --
(node:12008) UnhandledPromiseRejectionWarning: TimeoutError: waiting for target failed: timeout 30000ms exceeded
at Object.waitWithTimeout (C:\Users\afhassan\Puppy\node_modules\puppeteer\lib\cjs\puppeteer\common\helper.js:224:26)
at Browser.waitForTarget (C:\Users\afhassan\Puppy\node_modules\puppeteer\lib\cjs\puppeteer\common\Browser.js:269:45)
at ChromeLauncher.launch (C:\Users\afhassan\Puppy\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:100:27)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12008) [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.
错误是由这一行引起的
this._browser = await launch(CONFIG.launchOptions);
launch
从 Puppeteer 导入
import {
Browser,
Page,
launch,
CDPSession
} from 'puppeteer';
我的配置如下
{ verbose: true,
launchOptions: { headless: false },
defaultViewPort: { width: 1920, height: 1080 },
domain: 'domain.com',
mySiteDomain: 'domain.com',
users:
{ admin:
{ username: 'myusername',
password: 'mypassword' },
user0:
{ username: 'myusername',
password: 'mypassword' } },
tests: [ 'NameOfTest' ],
ignoreDefaultArgs: [ '--disable-extensions' ] }
我的 package.json 的相关部分如下
"dependencies": {
"puppeteer": "^5.5.0",
"yargs": "^15.4.1"
},
"devDependencies": {
"@types/puppeteer": "^5.4.2",
"@types/yargs": "^15.0.11",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
}
解决方案
推荐阅读
- php - MySQLi 列总和适用于一个查询,但不适用于另一个
- excel - 从列表中搜索关键字的列并将任何匹配项返回到不同的列
- mysql - MariaDB - INNODB 在创建增量记录时跳过数字序列 - 为什么?
- python - Python Tkinter 登录页面、循环和 .CSV
- plot - 使用“极坐标图”时的 SCILAB 未定义变量错误
- mongodb - 填写 MongoDB 上聚合的缺失日期
- amazon-web-services - AWS Cloudwatch 警报监控 ECS 容器状态
- php - 在 RegistrationController 中创建用户之前的验证
- flutter - Flutter:为什么 image_picker 不打开我画廊中的照片?
- protocol-buffers - protobuffers 中的重复字段是否保持插入的顺序?