sitespeed.io icon indicating copy to clipboard operation
sitespeed.io copied to clipboard

Error returned when running sitespeed from node modules : ERROR: Could not setup the Chrome Devtools Protocol Error: connect ECONNREFUSED ::1:9222

Open shawneenc opened this issue 3 years ago • 15 comments

Have you read the documentation?

URL

https://shawneentest-org.front.release.squads-dev.com

What are you trying to accomplish

Running sitespeed from node modules using the following command:

./node_modules/sitespeed.io/bin/sitespeed.js --multi "tests/expand-assignments.js" -n 1

This worked for me successfully before, but now the script starts to run and tries to open a chrome browser session that fails. The following error is returned: snconway@MBP-SNCONWAY performance-sitespeed % ./node_modules/sitespeed.io/bin/sitespeed.js --multi "tests/expand-assignments.js" -n 1

[2022-06-07 12:29:15] INFO: Versions OS: darwin 19.6.0 nodejs: v17.6.0 sitespeed.io: 21.6.1 browsertime: 14.18.1 coach: 7.0.0
[2022-06-07 12:29:16] INFO: Running tests using Chrome - 1 iteration(s)
[2022-06-07 12:29:19] ERROR: Could not setup the Chrome Devtools Protocol Error: connect ECONNREFUSED ::1:9222
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1158:16)
[2022-06-07 12:29:19] ERROR: Error: connect ECONNREFUSED ::1:9222
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1158:16)
[2022-06-07 12:29:19] ERROR: No data to collect
[2022-06-07 12:29:19] ERROR: Caught error from Browsertime TypeError: Cannot read properties of undefined (reading 'alias')
    at Object.processMessage (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/plugins/browsertime/index.js:167:52)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-06-07 12:29:19] ERROR: TypeError: Cannot read properties of null (reading 'split')
    at pathFromRootToPageDir (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/core/resultsStorage/pathToFolder.js:20:40)
    at Object.relativeSummaryPageUrl (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/core/resultsStorage/resultUrls.js:30:14)
    at DataCollector._addUrl (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/plugins/html/dataCollector.js:22:31)
    at DataCollector.addErrorForUrl (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/plugins/html/dataCollector.js:94:10)
    at Object.processMessage (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/plugins/html/index.js:58:27)
    at /Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/lib/core/queueHandler.js:213:32
    at drainItem (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:96:21)
    at Immediate.drain [as _onImmediate] (/Users/snconway/Documents/sitespeed2/performance-sitespeed/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:77:84)
    at processImmediate (node:internal/timers:466:21)

The following has been setup within visual studio to run from node modules:

  • sitespeed installed : npm i sitespeed.io
  • node-modules installed : npm i node-modules
  • dotenv installed : npm i dotenv

This was all working correctly up until approx a month ago - can someone please advise?

What browser did you use?

Chrome

How to reproduce

Follow the next steps to setup node modules locally:
- sitespeed installed : npm i sitespeed.io
- node-modules installed : npm i node-modules
- dotenv installed : npm i dotenv

Create a script and run using the following command: `./node_modules/sitespeed.io/bin/sitespeed.js --multi "tests/expand-assignments.js" -n 1 ` (ensure to overwrite "tests/expand-assignments.js" with the location and name of script you want to run

Relevant log output

see above

shawneenc avatar Jun 07 '22 11:06 shawneenc

Hi @shawneenc I think it could be a running Chrome instance that occupies that port. Can you try kill them all with pkill Chrome ?

soulgalore avatar Jun 08 '22 06:06 soulgalore

Hi @soulgalore,

Ran the command to kill chrome (mentioned above), the command to run the script is still failing with the same error messages.

Thanks

shawneenc avatar Jun 08 '22 07:06 shawneenc

Ok! Does it work if you test just one page?

Can you check if something else is using that port?

sudo lsof -PiTCP -sTCP:LISTEN

Then when I get some output like: Google 66227 peter 20u IPv4 0x5eef6f28e6657525 0t0 TCP localhost:9222 (LISTEN)

soulgalore avatar Jun 08 '22 08:06 soulgalore

Hi @soulgalore,

There is nothing else using that port: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME launchd 1 root 7u IPv6 0xac39ff5cb7ce862f 0t0 TCP *:22 (LISTEN) launchd 1 root 8u IPv4 0xac39ff5cb7cf2cbf 0t0 TCP *:22 (LISTEN) launchd 1 root 10u IPv6 0xac39ff5cb7ce862f 0t0 TCP *:22 (LISTEN) launchd 1 root 11u IPv4 0xac39ff5cb7cf2cbf 0t0 TCP *:22 (LISTEN) vpnagentd 102 root 5u IPv4 0xac39ff5cb7cf18ff 0t0 TCP localhost:29754 (LISTEN) vpnagentd 102 root 34u IPv4 0xac39ff5cbd54bf1f 0t0 TCP localhost:49171 (LISTEN) konea 111 root 11u IPv4 0xac39ff5cb7cf369f 0t0 TCP localhost:49162 (LISTEN) konea 111 root 19u IPv4 0xac39ff5cbd54e69f 0t0 TCP localhost:49167 (LISTEN) clientide 337 root 6u IPv4 0xac39ff5cbd54dcbf 0t0 TCP localhost:49565 (LISTEN) clientide 337 root 7u IPv4 0xac39ff5cbd54c8ff 0t0 TCP localhost:49558 (LISTEN) clientide 337 root 11u IPv4 0xac39ff5cbd54f07f 0t0 TCP localhost:49170 (LISTEN) detex 361 root 10u IPv4 0xac39ff5cc036db5f 0t0 TCP localhost:49197 (LISTEN) acumbrell 612 root 34u IPv4 0xac39ff5cbd54bf1f 0t0 TCP localhost:49171 (LISTEN) acumbrell 612 root 54u IPv4 0xac39ff5cc06a12df 0t0 TCP localhost:62722 (LISTEN) acumbrell 612 root 78u IPv4 0xac39ff5ccd0a1b5f 0t0 TCP localhost:61180 (LISTEN) acumbrell 612 root 86u IPv6 0xac39ff5cde21662f 0t0 TCP localhost:61181 (LISTEN) influxd 615 snconway 9u IPv4 0xac39ff5cc06a1cbf 0t0 TCP localhost:8086 (LISTEN) influxd 615 snconway 19u IPv6 0xac39ff5cc2da74cf 0t0 TCP *:8086 (LISTEN) influxd 615 snconway 48u IPv6 0xac39ff5cc2da7aef 0t0 TCP *:2003 (LISTEN) chronogra 633 snconway 10u IPv6 0xac39ff5cc2da500f 0t0 TCP *:8888 (LISTEN) Webex\x20 643 snconway 13u IPv4 0xac39ff5cbda9e07f 0t0 TCP localhost:49238 (LISTEN) dnscrypt- 51869 nobody 34u IPv4 0xac39ff5cbd54bf1f 0t0 TCP localhost:49171 (LISTEN) dnscrypt- 51869 nobody 47u IPv4 0xac39ff5cc8c0707f 0t0 TCP localhost:53 (LISTEN)

shawneenc avatar Jun 08 '22 09:06 shawneenc

Ok looks like nothing runs on the port, can you share the script so I can try to reproduce?

soulgalore avatar Jun 11 '22 20:06 soulgalore

Hi @soulgalore,

The same error occurs when I try to run any script. The problem is with launching the chrome browser - this did work up until approx a month ago (i.e. when running from node modules).

I have no issues when running lany of the same scripts locally using the docker command, like: docker run --shm-size=2g -v pwd:/sitespeed.io sitespeedio/sitespeed.io:11.0.0 --outputFolder assignment_output --speedIndex true --video true --multi ./tests/expand-assignments.js --browsertime.url https://shawneentest.front.develop.squads-dev.com --browsertime.login batch3_courseUser1 --block js-agent.newrelic.com --block www.google-analytics.com --block www.googletagmanager.com --block bam.nr-data.net --browsertime.viewPort 1366X768 --spa --browsertime.iterations 1

shawneenc avatar Jun 13 '22 09:06 shawneenc

any update on this @soulgalore - the issue is that node modules is failing to launch the actual browser - it has nothing to do with the script. The same thing happens when I try to run with all of our scripts

shawneenc avatar Jun 16 '22 07:06 shawneenc

I'm having a hard time to reproduce it? I can make the port configurable in the future (I don't think it is right now) but my guess is that there's something running on your computer? I would make sure to install latest sitespeed.io, latest Chrome, restart the computer and then try to run the tests again.

soulgalore avatar Jun 16 '22 13:06 soulgalore

Hi @soulgalore - have tried these things and they didnt work. Same issues happening for my colleagues also. Please make the port configurable

shawneenc avatar Jun 20 '22 11:06 shawneenc

Can you please try with --browsertime.chrome.enableChromeDriverLog and take the content of that log (it will be named chromedriver.log or something like that) and add it to a gist? See if we can get some more useful info of what goes wrong?

soulgalore avatar Jun 20 '22 20:06 soulgalore

Also wanted to check is theer any special reason you don't install the package globally?

soulgalore avatar Jun 21 '22 04:06 soulgalore

all I want to do here @soulgalore - is to run sitespeed locally via node modules, so I can watch the run as it as happening through this command: ./node_modules/sitespeed.io/bin/sitespeed.js --multi “tests/admin-report.js” -n 1

Have run the above command appending --browsertime.chrome.enableChromeDriverLog to it. chromedriver log attached - thanks

chromedriver.log

shawneenc avatar Jun 24 '22 17:06 shawneenc

I can see you use an old version of Chromdriver (97) so I think you use an old version of sitespeed.io, can you try to upgrade to latest?

The reason I asked about why not running globally was if there's any restrictions at your company to do so? Maybe also port restrictions etc and that could be the reason why it not work for you and your collegues.

I'll check if there's something to do about the port this weekend.

soulgalore avatar Jun 24 '22 20:06 soulgalore

I added a check if the port is used, you can try it by:

git clone https://github.com/sitespeedio/sitespeed.io.git
cd  sitespeed.io
npm install
bin/sitespeed.js  https://www.sitespeed.io -n 1 -b chrome

soulgalore avatar Jun 26 '22 21:06 soulgalore

This has been releases so you can test it by installing the latest release.

soulgalore avatar Jun 29 '22 21:06 soulgalore

Closing since I didn't get any feedback.

soulgalore avatar Dec 29 '23 05:12 soulgalore