lighthouse-lambda icon indicating copy to clipboard operation
lighthouse-lambda copied to clipboard

Errror: ECONNREFUSED

Open justin22 opened this issue 5 years ago • 10 comments

This is similar to #30, but even with the latest version, getting the following error.

"errorType": "Error",
    "errorMessage": "connect ECONNREFUSED 127.0.0.1:41901",
    "code": "ECONNREFUSED",
    "errno": "ECONNREFUSED",
    "syscall": "connect",
    "address": "127.0.0.1",
    "port": 41901,
    "stack": [
        "Error: connect ECONNREFUSED 127.0.0.1:41901",
        "    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)"
    ]

Any idea what could be wrong?

lighthouse-lambda: 3.1.1

code is basically the started template from the readme file

justin22 avatar Nov 26 '19 11:11 justin22

I'm getting the same thing with 3.1.1

trevsewell avatar Dec 08 '19 11:12 trevsewell

Same as my error, getting runtime lambda nodejs 10.x and 12.x . but working runtime nodejs8.10

kevsersrca avatar Dec 13 '19 09:12 kevsersrca

I'm seeing the same issue. Working fine for 8.10 but not 10.x or 12.x.

brandysnaps avatar Dec 18 '19 20:12 brandysnaps

I've made a quick workaround using this lib instead @serverless-chromium: https://github.com/alixaxel/chrome-aws-lambda.

Works with 10.x and 12.x.

npm install chrome-aws-lambda --save-prod

In https://github.com/joytocode/lighthouse-lambda/blob/master/lib/index.js:

const chromium = require('chrome-aws-lambda')
const chromeLauncher = require('chrome-launcher')
const lighthouse = require('lighthouse')

const defaultFlags = [
  '--headless',
  '--disable-dev-shm-usage',
  '--disable-gpu',
  '--no-zygote',
  '--no-sandbox',
  '--single-process',
  '--hide-scrollbars'
]

module.exports = async function createLighthouse (url, options = {}, config) {
  options.output = options.output || 'html'
  const log = options.logLevel ? require('lighthouse-logger') : null
  if (log) {
    log.setLevel(options.logLevel)
  }
  const chromeFlags = options.chromeFlags || defaultFlags
  return chromeLauncher.launch({ chromeFlags, chromePath: await chromium.executablePath })
    .then((chrome) => {
      options.port = chrome.port
      return {
        chrome,
        log,
        start () {
          return lighthouse(url, options, config)
        }
      }
    })
}

dordax avatar Jan 17 '20 12:01 dordax

@dordax this workaround 'almost' works for me but now I get a bunch of warn Caught exception: NO_TRACING_STARTED for each type of audit and the final report is just filled with errors instead of the data. My lambda works fine on 8.10 but just wanted to upgrade to keep with the times. Anything you changed in your handler function to go from 8.10 -> 12?

AlanSwenson avatar Jan 31 '20 20:01 AlanSwenson

if anyone else runs into this issue trying to use node 12, I did what @dordax did but I needed to remove '--single-process' to get the performance tests on lighthouse to stop returning errors

AlanSwenson avatar Jan 31 '20 23:01 AlanSwenson

Well consider 8.10 is now in maintenance (https://nodejs.org/en/about/releases/) this should probably be updated. I have a fork Im working on, if it works for me I'll open a PR.

smcelhinney avatar Feb 26 '20 15:02 smcelhinney

@smcelhinney did you get it working? I forked it a few weeks ago and changed a lot of things and got it working on node 12 on the local docker AWS instance but could never get it going on the actual lambda.

AlanSwenson avatar Feb 28 '20 16:02 AlanSwenson

I gave up on Lambda and moved my code to Google Cloud Run and Pub Sub topics :)

smcelhinney avatar Feb 28 '20 16:02 smcelhinney

I finally have a working solution in #37

AlanSwenson avatar Mar 12 '20 20:03 AlanSwenson