Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled 'error' event #604

Closed
LiangChen0323 opened this issue May 10, 2021 · 13 comments
Closed

Unhandled 'error' event #604

LiangChen0323 opened this issue May 10, 2021 · 13 comments

Comments

@LiangChen0323
Copy link

Hi

The CI server(TeamCity) that I am using is behind a proxy. When I run %lhci% collect --url="https://xxx/"
I got the below error message:

Running Lighthouse 3 time(s) on https://xxx/
  events.js:292
        throw er; // Unhandled 'error' event
        ^
  Error: spawn node ENOENT
      at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
      at onErrorNT (internal/child_process.js:469:16)
      at processTicksAndRejections (internal/process/task_queues.js:84:21)
  Emitted 'error' event on ChildProcess instance at:
      at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
      at onErrorNT (internal/child_process.js:469:16)
      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'spawn node',
    path: 'node',
    spawnargs: [
      'D:\\storage\\TOOLs\\Node\\12.18.2\\node_modules\\@lhci\\cli\\node_modules\\lighthouse\\lighthouse-cli\\index.js',
      'https://staging-web.ccleaner.com/',
      '--output',
      'json',
      '--output-path',
      'stdout',
      '--cli-flags-path',
      'D:\\work\\d861189cd355c9e2\\.lighthouseci\\flags-33da5e9f-3beb-41da-86c0-a859580f8d85.json'
    ]
  }

I also have environment variables for proxy: HTTP_PROXY, HTTP_PROXY_HOST and HTTP_PROXY_PORT
Any idea what the error really is about?

@patrickhulce
Copy link
Collaborator

Have the node_modules folders become corrupted @LiangChen0323? That error means that the file LHCI is trying to run is missing. As a first step, I'd try to reinstall LHCI after clearing away node_modules.

@LiangChen0323
Copy link
Author

Have the node_modules folders become corrupted @LiangChen0323? That error means that the file LHCI is trying to run is missing. As a first step, I'd try to reinstall LHCI after clearing away node_modules.

Hi @patrickhulce,

The build agent starts clean every time.
So I have to install the node package every time:
npm install -g @lhci/[email protected] --registry=xxx

@patrickhulce
Copy link
Collaborator

OK and D:\\storage\\TOOLs\\Node\\12.18.2\\node_modules\\@lhci\\cli\\node_modules\\lighthouse\\lighthouse-cli\\index.js is definitely a file that exists after you've finished installation?

@LiangChen0323
Copy link
Author

@patrickhulce

lhci healthcheck command worked:

  .lighthouseci/ directory writable
  Configuration file not found
  Chrome installation found
  Healthcheck passed!

@patrickhulce
Copy link
Collaborator

@LiangChen0323 healthcheck does not attempt to run Lighthouse itself (though after this, we'll probably add it to the list)

D:\storage\TOOLs\Node\12.18.2\node_modules\@lhci\cli\node_modules\lighthouse\lighthouse-cli\index.js is definitely a file that exists after you've finished installation?

Can you confirm this?

@LiangChen0323
Copy link
Author

LiangChen0323 commented May 10, 2021

@patrickhulce
yes, I can confirm that the file exists:

  Directory of D:\storage\TOOLs\Node\12.18.2\node_modules\@lhci\cli\node_modules\lighthouse\lighthouse-cli
  05/10/2021  06:54 PM    <DIR>          .
  05/10/2021  06:54 PM    <DIR>          ..
  10/26/1985  10:15 AM             4,635 bin.js
  10/26/1985  10:15 AM            20,017 cli-flags.js
  05/10/2021  06:54 PM    <DIR>          commands
  10/26/1985  10:15 AM               740 index.js
  10/26/1985  10:15 AM             2,611 printer.js
  10/26/1985  10:15 AM             9,473 run.js
  10/26/1985  10:15 AM             2,789 sentry-prompt.js
  05/10/2021  06:54 PM    <DIR>          test

@patrickhulce
Copy link
Collaborator

oh! It's node that does not exist! Is node not in the PATH of this build?

@LiangChen0323
Copy link
Author

node is not in the PATH but I have a reference in the build to where it is

@patrickhulce
Copy link
Collaborator

I have a reference in the build to where it is

Sorry, but what does this mean exactly? Unless node can be executed without erroring in the current environment, LHCI won't be able to run. We can add this to healtcheck but we can't really work around it.

@LiangChen0323
Copy link
Author

LiangChen0323 commented May 11, 2021

@patrickhulce

I added both node and npm to the Path, the error has changed, it seems it doesn't know how to connect to the url when the CI server is behind a proxy.
How can I tell lhci to use proxy to run tests?
I have environment variables such as HTTP_PROXY, HTTP_PROXY_HOST and HTTP_PROXY_PORT

@LiangChen0323
Copy link
Author

Hah, we figured it out.
We added chrome-flags: "--proxy-server=xxxx" to .lighthouserc.yaml

@patrickhulce
Copy link
Collaborator

it seems it doesn't know how to connect to the url

What specifically is trying to connect to which URL?

If the website you're analyzing needs a proxy to be reached, you'll need to use Chrome flags to communicate the proxy (https://www.chromium.org/developers/design-documents/network-settings).

If the LHCI server you're trying to reach needs a proxy to be reached, that's currently not supported out-of-the-box and you'll need to spinup a forwarding proxy and modify the --serverBaseUrl (see #574 for more options)

@patrickhulce
Copy link
Collaborator

Great! Glad you got it working 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants