报错:Navigation timeout of 30000 ms exceeded。puppeteer超时。通过更换浏览器解决

我的具体环境 和 解决方式可以看这个issue

2 个赞

aa22b8894122d309e334d3ff74de083c

2 个赞

噢snap啊,那正常

2 个赞

问题描述

  比如我用插件jrys-prpr,这个插件用到了puppeteer。我发送指令:jrysprpr
  机器人无回应,大概30s过后,机器人回复:渲染失败Navigation timeout of 30000 ms exceeded
  对应的控制台输出:

2025-02-18 22:03:29 [E] jrys-prpr 状态渲染失败 [2025-02-18T14:03:29.976Z]:  TimeoutError: Navigation timeout of 30000 ms exceeded 
at new Deferred (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/puppeteer-core/src/util/Deferred.ts:73:28) 
at Function.create (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/puppeteer-core/src/util/Deferred.ts:29:12) 
at new LifecycleWatcher (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/puppeteer-core/src/cdp/LifecycleWatcher.ts:148:42) 
at CdpFrame.setContent (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/puppeteer-core/src/cdp/Frame.ts:295:21)
at async CdpPage.setContent (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/puppeteer-core/src/api/Page.ts:1641:5) 
at async _Command.<anonymous> (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/koishi-plugin-jrys-prpr/lib/index.js:594:11) 
at async Array.<anonymous> (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/@koishijs/core/src/command/command.ts:291:14) 
at async _Command.execute (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/@koishijs/core/src/command/command.ts:307:22) 
at async <anonymous> (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/@koishijs/core/src/session.ts:444:22) 
at async Proxy.withScope (/home/bawuyinguo/SSoftwareFiles/koishi/awa-bot-winscp/awa-bot/awa-bot/node_modules/@koishijs/core/src/session.ts:343:22)

类似的问题同样也发生在其他使用puppeteer的插件中,比如:music-link, status-image。

2 个赞

解决方式:

先删掉snap的chrome:

snap list | grep chrom
sudo snap remove --purge chromium
snap list | grep chrom

然后去Chrome官网下载deb软件包并安装:

sudo dpkg -i ./google-chrome-stable_current_amd64.deb

然后找到chrome的二进制文件

bawuyinguo@bawuyinguo:~/SSoftwareFiles/chrome$ ls -la  /usr/bin/google-chrome
lrwxrwxrwx 1 root root 31  2月 19 01:22 /usr/bin/google-chrome -> /etc/alternatives/google-chrome
bawuyinguo@bawuyinguo:~/SSoftwareFiles/chrome$

然后在
puppeteer插件(koishi创建自带,GitHub - koishijs/koishi-plugin-puppeteer: Browser service | 浏览器服务)
或者
@shangxueink/puppeteer-without-canvas插件(koishi-shangxue-apps/plugins/puppeteer-without-canvas at main · shangxueink/koishi-shangxue-apps · GitHub)
的配置中,

将 启动设置 - executablePath 修改为 对应的二进制文件的路径,

在我的情景中,这里是’/usr/bin/google-chrome’

Image

问题解决

2 个赞

上学可爱捏(╹▽╹)

2 个赞