lighthouse: ECONNREFUSED When launching multiple Chrome instances

Hello! I don’t know why, but when I try to execute multiple instances of Chrome in a Linux env, I get this error:

[ERROR] connect ECONNREFUSED 127.0.0.1:39537
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)

I’ve been trying to find more information about this, but I don’t know where to start from.

Any idea about what may be the problem?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (5 by maintainers)

Most upvoted comments

@LucianoGanga

you have an error in your code when you upgraded to latest chrome-launcher.

heres the launch options you want:

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

you may also want --no-sandbox in there as well… I just ran into requiring that.

@LucianoGanga, you said after upgrading your hardware the problem was gone. Can you remember what exactly made the point?

We are running into the exact same problems when doing more than four lighthouse runs in parallel.

(node:28) UnhandledPromiseRejectionWarning: Error: not opened
    at WebSocket.send (/builds/xxx/xxx-4.0/node_modules/lighthouse/node_modules/ws/lib/WebSocket.js:344:18)
    at CriConnection.sendRawMessage (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/connections/cri.js:157:14)
    at CriConnection.sendCommand (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:55:10)
    at Driver.sendCommand (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:205:29)
    at Promise (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:870:19)
    at new Promise (<anonymous>)
    at Driver.endTrace (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:862:12)
    at pass.then._ (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/gather-runner.js:274:23)
    at <anonymous>
(node:28) 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(). (rejection id: 11)
(node:28) [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.
events.js:165
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:43219
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
Emitted 'error' event at:
    at Socket.socketErrorListener (_http_client.js:395:9)
    at Socket.emit (events.js:180:13)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at process._tickCallback (internal/process/next_tick.js:178:19)

Thank you for your feedback.

How are you launching and consuming chrome? Lighthouse as a node module? chrome-launcher and your own connection to Chrome?

If you’re using the latest chrome-launcher module, it should be waiting until the port is available but you’ll have to make sure you’re awaiting for the promise resolution before connecting.

@LucianoGanga, you said after upgrading your hardware the problem was gone. Can you remember what exactly made the point?

We are running into the exact same problems when doing more than four lighthouse runs in parallel.

(node:28) UnhandledPromiseRejectionWarning: Error: not opened
    at WebSocket.send (/builds/xxx/xxx-4.0/node_modules/lighthouse/node_modules/ws/lib/WebSocket.js:344:18)
    at CriConnection.sendRawMessage (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/connections/cri.js:157:14)
    at CriConnection.sendCommand (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:55:10)
    at Driver.sendCommand (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:205:29)
    at Promise (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:870:19)
    at new Promise (<anonymous>)
    at Driver.endTrace (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/driver.js:862:12)
    at pass.then._ (/builds/xxx/xxx-4.0/node_modules/lighthouse/lighthouse-core/gather/gather-runner.js:274:23)
    at <anonymous>
(node:28) 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(). (rejection id: 11)
(node:28) [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.
events.js:165
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:43219
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
Emitted 'error' event at:
    at Socket.socketErrorListener (_http_client.js:395:9)
    at Socket.emit (events.js:180:13)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at process._tickCallback (internal/process/next_tick.js:178:19)

Thank you for your feedback.

I also get same problems

I am able to reproduce this. here’s the steps

install travis node-js image

docker run --name travis-debug -dit travisci/ci-garnet:packer-1496954857 /sbin/init
docker exec -it travis-debug bash -l

setup things within the travis shell:

su - travis
mkdir tempproj && cd tempproj
yarn init # enter, enter, enter, enter...
yarn add chrome-launcher

then create an index.js with the code from @LucianoGanga’s comment above. and run:

node index.js

Thanks for circling back around to let us know! That certainly would explain my difficulty reproing on a 64-core linux box 😃

Feel free to reach out again if you run into new issues!

Any comments will be really appreciated! We’re currently blocked with this!

Anyone? @patrickhulce?

So far, It appears to be an specific Linux problem (because it works fine in our macs, but not on our servers):

We’re basically reproducing this on Linux when:

const chromeInstance = require('lighthouse/chrome-launcher')
chromeOptions = {
    port: 0,
    autoSelectChrome: true, // False to manually select which Chrome install.
    additionalFlags: ['--disable-gpu', '--headless', '--enable-logging']
  }

chromeInstance.launch(chromeOptions)
// Instance 1 -> Chrome Launched succesfully

chromeInstance.launch(chromeOptions)
// Instance 2 -> Chrome Launched succesfully

chromeInstance.launch(chromeOptions)
// Instance 3 -> Error: connect ECONNREFUSED 127.0.0.1:60520

chromeInstance.launch(chromeOptions)
// Instance 4 -> Error: connect ECONNREFUSED 127.0.0.1:40814

Can you help us to reproduce if you’re getting the same error on your Linux env?