我遇到了以下问题。
这是错误消息:
Error: Navigation failed because browser has disconnected!
at /Users/me/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:51:147
at /Users/me/myproject/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:47:62
at Array.map (<anonymous>)
at Object.emit (/Users/me/myproject/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:47:43)
at CDPSession.emit (/Users/me/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
at CDPSession._onClosed (/Users/me/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:247:14)
at Connection._onMessage (/Users/me/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:94:25)
at WebSocket.<anonymous> (/Users/me/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/WebSocketTransport.js:13:32)
at WebSocket.onMessage (/Users/me/myproject/node_modules/ws/lib/event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
这是我正在阅读的文档:
timeout <number> Specify a timeout for all tasks. Defaults to 30000 (30 seconds).
[src](https://github.com/thomasdondorf/puppeteer-cluster#clusterlaunchoptions)
我的每项任务都是约 34 秒,所以大多数时候它会失败(30 秒后超时),但偶尔它会成功。
其他 GitHub/Stack Overflow 的答案也提到了await
代码中的缺失也可能导致相同的错误消息。