harlan-zw / unlighthouse

Scan your entire site with Google Lighthouse in 2 minutes (on average). Open source, fully configurable with minimal setup.
https://unlighthouse.dev
MIT License
3.68k stars 105 forks source link

unlighthouse-ci stuck if / returns 404 #159

Closed mastoj closed 4 months ago

mastoj commented 10 months ago

Describe the bug

I'm running unlighthouse-ci against a site that requires an auth cookie. When the cookie is wrong I will get a 404, which is as expected. What isn't expected though is unlighthouse to be stuck.

Output from unlighthouse:

ℹ Using system chrome located at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome.                                                          Unlighthouse 12:35:54 PM

 WARN  Request to site XXXX threw an unhandled exception. Please check the URL is valid. Request failed with status code 401        Unlighthouse 12:35:54 PM

  at settle (/Users/tomas/.nvm/versions/node/v18.16.1/lib/node_modules/@unlighthouse/cli/node_modules/axios/lib/core/settle.js:19:12)
  at IncomingMessage.handleStreamEnd (/Users/tomas/.nvm/versions/node/v18.16.1/lib/node_modules/@unlighthouse/cli/node_modules/axios/lib/adapters/http.js:570:11)
  at IncomingMessage.emit (node:events:525:35)
  at endReadableNT (node:internal/streams/readable:1359:12)
  at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

 ERROR  Site check failed. will attempt to proceed but may fail.                                                                                          Unlighthouse 12:35:54 PM

 WARN  You seem to be missing a robots.txt.                                                                                                               Unlighthouse 12:35:54 PM

ℹ Sitemap appears to be missing, falling back to crawler mode.                                                                                           Unlighthouse 12:35:54 PM
ℹ Skipping /. Invalid response from URL XXXX code: 404. 

Reproduction

unlighthouse-ci --site your.protected.site.com
truthdomains commented 7 months ago

To add to this; we actually want unLighthouse to test our 404, but it won't - even when explicitly added to the urls array in the config.

Maybe there should be a config to ignore the the HTTP status code?

harlan-zw commented 4 months ago

Testing non-200 result pages is out of scope of the project I'm sorry.

I'd suggest providing a valid Cookie before starting the scan or setting up an authentication workflow if you don't know the cookie ahead of time.