【问题标题】:Lighthouse reporting is failing in Jenkins with below error詹金斯的灯塔报告失败,错误如下
【发布时间】:2021-08-16 13:39:25
【问题描述】:
Fri, 28 May 2021 09:27:18 GMT ChromeLauncher Waiting for browser.............................................................................................
Fri, 28 May 2021 09:27:19 GMT ChromeLauncher Waiting for browser...............................................................................................
Fri, 28 May 2021 09:27:19 GMT ChromeLauncher Waiting for browser.................................................................................................
Fri, 28 May 2021 09:27:20 GMT ChromeLauncher Waiting for browser...................................................................................................
Fri, 28 May 2021 09:27:20 GMT ChromeLauncher Waiting for browser.....................................................................................................
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher Waiting for browser.......................................................................................................

Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:36157
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error Logging contents of /tmp/lighthouse.mOZ6RIf/chrome-err.log
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
Inconsistency detected by ld.so: ../elf/dl-tls.c: 488: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!

Unable to connect to Chrome
370/0: Lighthouse analysis FAILED for https://website.com/en/....
rm: no such file or directory: report/lighthouse/website/en....report.json

/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:219
   const score = toScore(summary.detail.performance)

TypeError: Cannot read property 'performance' of undefined
   at checkBudgets (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:219:42)
   at /var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:67:20
   at Array.map (<anonymous>)
   at execute (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:39:38)
   at Object.<anonymous> (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/run.js:28:1)
   at Module._compile (internal/modules/cjs/loader.js:1068:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
   at Module.load (internal/modules/cjs/loader.js:933:32)
   at Function.Module._load (internal/modules/cjs/loader.js:774:14)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Lighthouse_Reports@1.0.0 lighthouse: `lighthouse-batch -f sites.txt -p --config-path=config.js -h --performance 75 --score 70 --no-report –chrome-flags='–headless','--no-sandbox'`
npm ERR! Exit status 1

我正在为 900 多个页面 url 运行此报告。

【问题讨论】:

    标签: node.js jenkins npm lighthouse


    【解决方案1】:

    如日志所示,ChromeLauncher 拒绝连接到 Jenkins。您可能想检查是否允许 Jenkins 访问此正在运行的服务。

    如果您的 ChromeLauncherheadless 模式下运行,或者 ChromeLauncher 的多个实例正在运行,并且没有剩余可用端口,也会发生这种情况。 p>

    您可以尝试将以下内容添加到您的 ChromeLauncher 启动配置中。事实上,你应该提到这些。

    chromeOptions = {
            chromeFlags: ["--disable-gpu", "--headless", "--enable-logging"] 
    }
    

    查找此here 的更多详细信息。

    作为替代方案,您可以考虑在 Docker 中运行 Lighthouse,以将其与 Jenkins 隔离。这样,您可以扫描您的项目,生成 HTML 报告并将其发布回 Jenkins。

    您可以按照here提到的方法。

    【讨论】:

    • 感谢您的回复,我已经在使用“-headless”标志并尝试使用您提到的那些标志,但仍然面临同样的问题。我想,我应该尝试 docker 方法。我们可以为这个灯塔报告运行的页面 URL 数量是否有任何限制?
    • @rajumuddana 据我所知,没有这样的限制。只要确保开源版本中没有任何官方限制即可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多