Puppeteer的工作无头,但不是很头心色(JS)

发布于 2025-02-06 16:47:35 字数 681 浏览 1 评论 0原文

我正在Linux VM上运行Puppeteer,该Linux VM没有显示器;但是,我正在使用XVFB来解决这个问题。

对于某些背景:该程序的总体目标是导航到页面并使用Puppeteer进行身份验证。从那里,我使用Lighthouse审核了几个网页。 我已经在无头的无问题上运行了几个星期。我最近发现,通过通过Chrome Developer工具在本地机器上运行手动测试,无头灯塔的性能指标远胜于现实。如果是相关的,我特别注意到记录的DOM节点数量存在巨大差距。 长话短说,我现在需要以扎实的模式运行此脚本。

在代码中安装和实现XVFB后,我已经能够在脚本中启动显示器而不会遇到任何错误。我将这个问题的答案用作参考: with xfvvb headless andund puppeteer >

将所有这些内容付诸实践,将所有这些脚本(包括XVFB实现)在无头模式下运行,尽管不断运行,但该脚本仍然在无头模式下运行。当我尝试以令人头疼的方式运行它时,即使我尝试将超时时间扩大到5分钟,我也会始终如一地超时。我尝试了荒谬的发射选项组合,但无济于事。即使这意味着要大大改变我对问题的方法,所有和所有的帮助都将受到极大的赞赏。谢谢你!

I am running puppeteer on a Linux VM, which does not have a display; however, I am using xvfb to remedy that.

For some background: The overall goal of this program is to navigate to a page and authenticate using puppeteer. From there, I audit several webpages using Lighthouse.
I have been running this script for several weeks in headless no issues. I've recently found that the performance metrics of the headless Lighthouse runs far better than reality by running manual tests on my local machine through chrome developer tools. If it's relevant, I specifically noticed a huge gap in the number of recorded DOM nodes. Long story short, I now need to run this script in headful mode.

After installing and implementing xvfb in my code, I have been able to start a display within my script without hitting any errors. I used the answer from this question as reference: Running Puppeteer with xfvb headless : false

With all of that out of the way, onto the actual issue: this script, including the xvfb implementation, still runs flawlessly in headless mode with absolutely no timeouts despite repeated runs. When I try running it in headful mode, I consistently timeout on the puppeteer launch, even when I tried extending the timeout to 5 minutes. I've tried an absurd amount of launch-option combinations to no avail. Any and all help would be so greatly appreciated, even if it means significantly altering my approach to the problem. Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文