【问题标题】:Puppeteer UnhandledPromiseRejectionWarning [closed]Puppeteer UnhandledPromiseRejectionWarning [关闭]
【发布时间】:2021-11-01 09:29:36
【问题描述】:

从台式机换成笔记本电脑后,每次尝试运行 puppeteer 程序时都会出现以下错误:

(node:69) UnhandledPromiseRejectionWarning: TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r901912 is guaranteed to work.
    at Timeout.onTimeout (/mnt/c/Users/trgre/OneDrive/Desktop/puppeteer-Core/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:208:20)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
(node:69) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:69) [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.

【问题讨论】:

  • 欢迎来到 Stack Overflow!寻求调试帮助的问题必须包括所需的行为以及在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。请参阅:How to create a Minimal, Complete, and Verifiable example
  • 请提供足够的代码,以便其他人更好地理解或重现问题。
  • 除了代码之外,您的每个不同设备上还有哪些操作系统/环境设置?我们不知道哪些变量可能导致该问题,因此请尝试提供诊断所需的背景信息。

标签: javascript node.js puppeteer


【解决方案1】:

最可能的原因是 Puppeteer 驱动程序与您的 Chromeium 版本不匹配。

来自文档:

注意:当您安装 Puppeteer 时,它会下载最新版本的 Chromium(~170MB Mac,~282MB Linux,~280MB Win),保证 使用 API。要跳过下载,请下载到另一个路径, 或下载其他浏览器,请参阅Environment variables

在那里你会找到一个环境变量:PUPPETEER_CHROMIUM_REVISION

或者,您可以重新安装 Puppeteer 并允许它安装正确版本的 Chromium。

【讨论】:

    猜你喜欢
    • 2019-03-16
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-17
    相关资源
    最近更新 更多