sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.74k stars 601 forks source link

ECONNREFUSED when element not found #3847

Open srvraja opened 1 year ago

srvraja commented 1 year ago

Have you read the documentation?

URL

https://demoqa.com/

What are you trying to accomplish

I am experiencing an issue while running a scripted journey in which it is attempting to perform an operation on a 'not found element.' I have tried running the journey for 3 iterations. The scripted journey has 2 measurements, one for launch and the other for clicking where the element is not found.

The first iteration failed with an error indicating that the element was not found. The journey continued to the second iteration, but it failed immediately after launching the second iteration(even measurement for launch didn't happen). I have provided the version used and the specific error that was reported below. Additionally, I have attached the script for your reference. trial_journey_issue.txt

INFO: Versions OS: win32 10.0.14393 nodejs: v16.15.0 sitespeed.io: 25.7.3 browsertime: ^16.13.3 coach: 7.1.2

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:51177 at ClientRequest. (C:\SitespeedioMain\sitespeed.io-main\node_modules\selenium-webdriver\http\index.js:294:15) at ClientRequest.emit (node:events:527:28) at Socket.socketErrorListener (node:_http_client:454:9) at Socket.emit (node:events:527:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21)

What browser did you use?

Chrome

How to reproduce

Please use the attached script to reproduce

Relevant log output

[2023-05-17 03:18:29] INFO: Versions OS: win32 10.0.14393 nodejs: v16.15.0 sitespeed.io: 25.7.3 browsertime: ^16.13.3 coach: 7.1.2
[2023-05-17 03:18:33] INFO: Running tests using Chrome - 3 iteration(s)

DevTools listening on ws://127.0.0.1:9222/devtools/browser/9b5ba524-446a-4a00-a75e-d626245b4809
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1"
[2112:2188:0517/031837.023:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1"
[2112:2188:0517/031837.315:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1"
[2112:2188:0517/031837.374:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1"
[2112:2188:0517/031837.396:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1"
[2112:2188:0517/031837.407:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1"
[2112:2188:0517/031837.412:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1"
[2112:2188:0517/031837.414:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1"
[2112:2188:0517/031837.416:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1"
[2112:2188:0517/031837.416:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1"
[2023-05-17 03:18:37] INFO: Start to measure homepage_trial
[2023-05-17 03:18:37] INFO: Navigating to url https://www.dummy.com/ iteration 1
[2023-05-17 03:18:47] INFO: Take after page complete check screenshot
[2023-05-17 03:18:49] INFO: Take cumulative layout shift screenshot
[2023-05-17 03:18:51] INFO: Take largest contentful paint screenshot
[2023-05-17 03:18:55] INFO: Start to measure click_on_accept_button
[2023-05-17 03:18:55] ERROR: Couldn't execute script named CUSTOM error:JavascriptError: javascript error: Cannot read properties of null (reading 'click')
  (Session info: chrome=113.0.5672.94)
[2023-05-17 03:18:55] ERROR: Could not find element by xpath //*[@id="onetrust-accept-btns-handlers"]
[2023-05-17 03:18:55] ERROR: Error: Could not find element by xpath //*[@id="onetrust-accept-btns-handlers"]
    at Click.byXpathAndWait (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\command\click.js:159:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async module.exports (C:\Sitespeedio\sitespeed-script\1.js:20:4)
    at async C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\run.js:7:9
    at async Iteration.run (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\iteration.js:223:9)
    at async Engine.runByScript (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\index.js:270:20)
    at async Object.analyzeUrl (C:\SitespeedioMain\sitespeed.io-main\lib\plugins\browsertime\analyzer.js:171:21)
    at async Object.processMessage (C:\SitespeedioMain\sitespeed.io-main\lib\plugins\browsertime\index.js:150:26)
[2023-05-17 03:18:55] INFO: https://www.dummy.com/ TTFB: 475ms DOMContentLoaded: 1.59s firstPaint: 1.28s FCP: 1.28s LCP: 1.28s Load: 2.91s TBT: 173ms CLS:0.0004
[2023-05-17 03:18:56] INFO: C:\Sitespeedio\sitespeed-script\1.js

DevTools listening on ws://127.0.0.1:9222/devtools/browser/0245ce8e-8b5c-4b2b-a35f-9d92227d64e9
[3232:3108:0517/031856.784:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1"
[3232:3108:0517/031856.784:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1"
[3232:3108:0517/031856.799:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1"
[3232:3108:0517/031856.799:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1"
[3232:3108:0517/031856.830:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1"
[3232:3108:0517/031856.846:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1"
[3232:3108:0517/031856.846:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1"
[3232:3108:0517/031856.846:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1"
[3232:3108:0517/031857.004:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1"
[3232:3108:0517/031857.039:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1"
[3232:3108:0517/031857.094:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1"
[3232:3108:0517/031857.149:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1"
[3232:3108:0517/031857.150:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1"
[3232:3108:0517/031857.161:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1"
[3232:3108:0517/031857.164:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1"
[3232:3108:0517/031857.165:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1"
[2023-05-17 03:18:57] INFO: Start to measure homepage_trial
[2023-05-17 03:18:57] INFO: Navigating to url https://www.dummy.com/ iteration 2
C:\SitespeedioMain\sitespeed.io-main\node_modules\selenium-webdriver\http\index.js:294
      onError(new Error(message))
              ^

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:51177
    at ClientRequest.<anonymous> (C:\SitespeedioMain\sitespeed.io-main\node_modules\selenium-webdriver\http\index.js:294:15)
    at ClientRequest.emit (node:events:527:28)
    at Socket.socketErrorListener (node:_http_client:454:9)
    at Socket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
soulgalore commented 1 year ago

Hi @srvraja thank you for creating the issue. Hmm you get error messages from "Failed parsing rule" - I haven't seen that either before.

I guess ECONNREFUSED 127.0.0.1:51177 is for Chrome dev tools, but it seems like high port number.

If you upgrade to use latest sitespeed.io (that way you will get newer versions of Chromedriver) do you get the same error?

Best Peter

srvraja commented 1 year ago

@soulgalore

Thanks for your time.

I downloaded the latest version(sitespeed v27.6.4, Node.js v18.16.0) and got the below error. Are any other configurations missing?

node:internal/errors:490 ErrorCaptureStackTrace(err); ^

TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file at open (node:internal/fs/promises:538:10) at readFile (node:internal/fs/promises:909:20) at parseCommandLine (file:///C:/SitespeedioMain/sitespeed.io-main/lib/cli/cli.js:2050:13) at start (file:///C:/SitespeedioMain/sitespeed.io-main/bin/sitespeed.js:119:22) at file:///C:/SitespeedioMain/sitespeed.io-main/bin/sitespeed.js:178:7 { code: 'ERR_INVALID_URL_SCHEME' }

srvraja commented 1 year ago

@soulgalore

The above 'ERR_INVALID_URL_SCHEME' got resolved when I renamed the scripted file from demo.js to demo.cjs.

The initial reported issue persisted in the latest sitespeed version.

[2023-05-22 10:14:30] INFO: Versions OS: win32 10.0.14393 nodejs: v18.16.0 sitespeed.io: 25.7.3 browsertime: ^16.13.3 coach: 7.1.2 [2023-05-22 10:14:31] INFO: Running tests using Chrome - 3 iteration(s) [4300:2448:0522/101431.865:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1" [4300:2448:0522/101431.881:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1"

DevTools listening on ws://127.0.0.1:9222/devtools/browser/9ac46f47-6a57-469c-b6a0-073210ec7d83 [4300:2448:0522/101432.029:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1" [4300:2448:0522/101432.047:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1" [4300:2448:0522/101432.053:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1" [4300:2448:0522/101432.055:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1" [4300:2448:0522/101432.063:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1" [4300:2448:0522/101432.079:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1" [4300:2448:0522/101432.080:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1" [4300:2448:0522/101432.081:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1" [2023-05-22 10:14:32] INFO: Start to measure homepage_trial [2023-05-22 10:14:32] INFO: Navigating to url https://www.dummy.com/ iteration 1 [2023-05-22 10:14:42] INFO: Take after page complete check screenshot [2023-05-22 10:14:44] INFO: Take cumulative layout shift screenshot [2023-05-22 10:14:46] INFO: Take largest contentful paint screenshot [2023-05-22 10:14:49] INFO: Start to measure click_on_accept_button [2023-05-22 10:14:49] ERROR: Couldn't execute script named CUSTOM error:JavascriptError: javascript error: Cannot read properties of null (reading 'click') (Session info: chrome=113.0.5672.127) [2023-05-22 10:14:49] ERROR: Could not find element by xpath //[@id="onetrust-accept-btns-handlers"] [2023-05-22 10:14:49] ERROR: Error: Could not find element by xpath //[@id="onetrust-accept-btns-handlers"] at Click.byXpathAndWait (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\command\click.js:159:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async module.exports (C:\Sitespeedio\sitespeed-script\1.cjs:20:4) at async C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\run.js:7:9 at async Iteration.run (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\iteration.js:223:9) at async Engine.runByScript (C:\SitespeedioMain\sitespeed.io-main\node_modules\browsertime\lib\core\engine\index.js:270:20) at async Object.analyzeUrl (C:\SitespeedioMain\sitespeed.io-main\lib\plugins\browsertime\analyzer.js:171:21) at async Object.processMessage (C:\SitespeedioMain\sitespeed.io-main\lib\plugins\browsertime\index.js:150:26) [2023-05-22 10:14:49] INFO: https://www.dummy.com/ TTFB: 518ms DOMContentLoaded: 1.99s firstPaint: 1.43s FCP: 1.43s LCP: 1.65s Load: 3.01s TBT: 436ms CLS:0.0047 [2023-05-22 10:14:50] INFO: C:\Sitespeedio\sitespeed-script\1.cjs

DevTools listening on ws://127.0.0.1:9222/devtools/browser/ff1da3aa-36d9-4142-95ce-7d8ddc5f8aaa [4360:520:0522/101450.835:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1" [4360:520:0522/101450.838:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1" [4360:520:0522/101450.839:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1" [4360:520:0522/101450.841:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1" [4360:520:0522/101450.842:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1" [4360:520:0522/101450.843:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1" [4360:520:0522/101450.844:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1" [4360:520:0522/101450.845:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1" [4360:520:0522/101450.960:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP cache.pack.google.com 127.0.0.1" [4360:520:0522/101450.992:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP clients1.google.com 127.0.0.1" [4360:520:0522/101450.998:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP update.googleapis.com 127.0.0.1" [4360:520:0522/101451.101:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP redirector.gvt1.com 127.0.0.1" [4360:520:0522/101451.108:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP laptop-updates.brave.com 127.0.0.1" [4360:520:0522/101451.113:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP offlinepages-pa.googleapis.com 127.0.0.1" [4360:520:0522/101451.115:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP edge.microsoft.com 127.0.0.1" [4360:520:0522/101451.117:ERROR:host_mapping_rules.cc(146)] Failed parsing rule: "MAP optimizationguide-pa.googleapis.com 127.0.0.1" [2023-05-22 10:14:51] INFO: Start to measure homepage_trial [2023-05-22 10:14:51] INFO: Navigating to url https://www.dummy.com/ iteration 2 C:\SitespeedioMain\sitespeed.io-main\node_modules\selenium-webdriver\http\index.js:294 onError(new Error(message)) ^

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:57652 at ClientRequest. (C:\SitespeedioMain\sitespeed.io-main\node_modules\selenium-webdriver\http\index.js:294:15) at ClientRequest.emit (node:events:513:28) at Socket.socketErrorListener (node:_http_client:502:9) at Socket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

TerryJLU commented 1 year ago

issue Face the same issue ,It is good with old version 26

soulgalore commented 1 year ago

Hi @TerryJLU hmm, I tried the same on a windows GitHub action and there it seems to work: https://github.com/sitespeedio/sitespeed.io/blob/main/.github/workflows/windows.yml#L29-L31

I see NodeJS 18.16.0, can you verify that it's the same version as in node.exe? I guess it is but just wanted to 100% sure.

TerryJLU commented 1 year ago

Yes NodeJS 18.16.0

srvraja commented 1 year ago

@soulgalore ,

any chance of looking into 'Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:57652' where the execution got crashed when one of the elements not available in the rendered page? You can use the attached script to reproduce it. It is happening with latest version as well.

Thanks for your time, please let me know if you need more information.

soulgalore commented 1 year ago

@srvraja let me try and add your script to the tests on GitHub action, so I also get that error.

soulgalore commented 1 year ago

Hi @srvraja hmm we don't get the same here, you can checkout the log from the test here: https://github.com/sitespeedio/sitespeed.io/actions/runs/5266889131/jobs/9521425698?pr=3884

The only difference is that you run the global install. I did a try some time ago to install it globally in the action but my Windows knowledge failed, can you help me to get it installed correctly? Here's a PR for installing sitespeed.io globally on the Windows GitHub action: https://github.com/sitespeedio/sitespeed.io/pull/3860

soulgalore commented 9 months ago

I updated the PR to try to run with a global install to try to reproduce.

soulgalore commented 9 months ago

I could reproduce this on Windows in a GitHub action. When the element do not exists, I get a ECONNREFUSED but I haven't been able to figure out why.

srvraja commented 7 months ago

@soulgalore ,

Any luck to overcome this?

Gone through the issue https://github.com/sitespeedio/sitespeed.io/issues/4078, will the error handling fix this?

Thanks

soulgalore commented 7 months ago

I'm not sure, this seems to only happens on Windows. I wonder if people are also seeing this using only Selenium or if it's something on our side? I'm having a problem fixing it since I do not have a windows machine.

srvraja commented 7 months ago

@soulgalore I have tested from Mac and RHEL8 instances, getting the same error if the object not found in the scripted journey.

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:59974 at ClientRequest. (/Users/testUser/.nvm/versions/node/v16.14.2/lib/node_modules/sitespeed.io/node_modules/selenium-webdriver/http/index.js:296:15) at ClientRequest.emit (node:events:526:28) at Socket.socketErrorListener (node:_http_client:442:9) at Socket.emit (node:events:526:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21)

Thanks

soulgalore commented 7 months ago

So you get ECONNREFUSED? Ok can you share a minimal example script that I can use to reproduce? Thanks!

srvraja commented 7 months ago

Hi @soulgalore ,

Attaching a script which will do the following. I have tested this in Mac, getting the same ECONNREFUSED error.

  1. Navigate to sitespeed.io site
  2. click on brand logo with class name
  3. click again on brand logo with wrong class name [This step is to simulate 'Trying to click an object which doesn't exist'] issue_debug.js.zip
soulgalore commented 7 months ago

Ah thank you @srvraja for taking the time to make the script! I'll have a look.

soulgalore commented 7 months ago

Hi @srvraja in your script you are throwing an error in the catch block, that's what is causing it. I can fix so we catch that better but I also think it's better not to re-throw. Mark your test as an error and then exit.