Is there a way to run Google Lighthouse tests headlessly? - google-chrome

So I'm trying to programmatically conduct Google Lighthouse audits on several webpages, and I'm running into an issue. After installing Chrome and node/npm/lighthouse on an Amazon Linux 2 EC2 instance, I am able to successfully run LightHouse tests when I initiate a GUI session and run a command from a terminal within the GUI (this launches chrome and conducts the test as usual) but I am unable to do the same thing from the command line. This is the error I get when launching lighthouse.
ChromeLauncher:error [42565:42565:0516/170626.787500:ERROR:brower_main_loop.cc (1386) Unable to open X display.
While there are a couple of other errors, I believe this is the one I should be paying attention to, because when I try to just launch Google Chrome, that is the exact error I get, so I am inclined to believe it is an issue with trying to launch on a display.
I've also tried the "--headless" option when launching chrome and get
[0516/171128.450564:WARNING:headless_browser_main_parts.cc(83)] Cannot create Pref Service with no user data dir. [0516/171128.521499:ERROR:vaapi_wrapper.cc(594)] Could not get a valid VA display [0516/171128.524992:ERROR:gpu_init.cc(426)] Passthrough is not supported, GL is egl
Another user with a similar question decided to use the Google Pagespeeds API, which will not a be a solution for me-- it needs to be done locally.
Because this works fine on a GUI session with the same server, I really think it's just a display rendering issue, but I don't know how to solve this. Maybe "simulating" a display? I've also tried entering export DISPLAY=1:0, which apparently worked for some users and caused me to stop seeing the error, but the functionality was still broken when running the audit.
Any help would be so useful!!

Information found in this stackoverflow question was infinitely helpful. Although I still get a slew of errors when I try to launch the browser, I can successfully run LightHouse and audit the pages I want to without any errors.

Related

All service workers fail to register with "TypeError: An unknown error occurred when fetching the script." – but only on Chrome

My copy of Google Chrome, on my laptop, fails to register all service workers. If I load any website that has offline functionality, devtools console outputs:
Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://googlechrome.github.io/samples/service-worker/basic/') with script ('https://googlechrome.github.io/samples/service-worker/basic/service-worker.js'): An unknown error occurred when fetching the script.
Note that the above error is from https://googlechrome.github.io/samples/service-worker/basic/, which is a technology demonstration made by google, specifically about service workers, specifically for chrome, not something I created. One other interesting thing is that service workers fetched from localhost can be registered with no problem. This would suggest an SSL issue (I think), but then again the host of the above website is github pages (is there any way my browser could be not trusting github pages? I haven't found any evidence to support that).
I get the same error if I directly type navigator.serviceWorker.register("https://googlechrome.github.io/samples/service-worker/basic/service-worker.js"); into the console on the same site.
It's not just a console message: if I load the website, then disconnect from the internet, then refresh the page, the browser reports "no internet" and does not load the website. The same thing happens if I use devtools>Application>Service Workers offline mode. This indicates that the service worker is failing to register. However, the Service Workers devtools tab does show service workers present – it just lists them as "redundant" instead of "active and running". Bizarrely, the "time received" is 1970-01-01.
I'm using Google Chrome Version 89.0.4389.114 (Official Build) (x86_64) on MacOS Big Sur. On other browsers (Safari, Firefox, and any browser on any other computer/mobile device), this error does not occur. I have restarted my Chrome multiple times since I first noticed the error, and updated it once since then. Neither fixed it.
I'm aware of a couple similar SO questions (here and here for example), but all of them have accepted answers about how the website creators can fix bugs in their site. This bug is appearing on websites I did not create, and seems specific to my browser (which I haven't tampered with in any way). The main reason this is driving me nuts is that I really really like Chrome's devtools, and I would like to use them for a current PWA project.
If anyone familiar with Chrome's inner workings knows what could be causing this, or if anyone has solved this in the past, I will be forever in your debt.

error on Google Page Speed Insights and doesn't run on one website I made,

I tried to run Google Page Speed Insights and got this error message. I've searched and can't seem to find how to fix that. I also ran Page Speed Insights with other websites that I made and every time it worked.
Lighthouse returned error: FAILED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_CONNECTION_FAILED)
https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fexecfarm.com%2F
Several of us in comments
have tried the link you gave and have not experienced any errors.
However, I have been refreshing the page and the Google Speed insights result has been showing different values for the page overall score From 34%, to 40% to 70% (then back to 40%).
This would possibly imply that the page is being worked on or that there is some other (database) stuff that is changing each time the page is loaded.
If you are not cloudhosting (ie Cached copies) then when your server is taking up a new file uploaded from your IDE, while that file is uploaded to the server it can not be "read" while it's being "written". So maybe Google is trying to access the file when it is being replaced which will cause momentary drops.
You should also be forcing the HTTPS, currently the website is still fully accessible on the insecure http://execfarm.com URL.
try to force redirection to https instead of http by activate SSL
I tried the test 10 times and all of them failed with
Lighthouse returned error: FAILED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_CONNECTION_FAILED)
This could mean multiple things. Either your page failed to render in Google's PageSpeed Insights, an internet backbone broke, or something else happened.
It may be that an internet backbone outage that caused your server's connection with Google to be broken. When an internet backbone outage happens, user A may be able to connect to your server, but user B may not. To rule this out, check your logs when you go to your Google PageSpeed Insights and look for any IP address associated with Google's IPs.
To rule out that page rendering is the cause, move your index.html file to somewhere else, and replace it with a dummy index.html, to ensure that page rendering isn't the cause.
To rule out an internet backbone outage, switch to a temporary server and move everything there. If Google PageSpeed Insights works, then you know that it was an internet backbone outage.
Hope this helps.
I faced this problem because of my SSL integration. After fixed it, my problem solved. Try to run lighthouse test without SSL.
Also please check this answer:
This issue is quite often reported by many users.
It occurs because of the following issues:
Unresponsive server Unstable internet connection. Please try to rerun
the test then it will work.
For more clear and better result follow instructions in this link.
https://stackoverflow.com/a/53318088/4766521

Azure APIM Fails to Create API from Function App

When I try to create an API in APIM by using Create from Function App, I fill out the fields and click Create. The operation provides the wait dots and comes back in five seconds and says
Could not create an API. Please try again later.
I can create a blank API...but not one from an existing Function App. I have tried multiple combinations, No products, all products, no version, version..etc. No luck.
Thoughts?
Notes
The function in question is an HTTP Trigger.
The function works locally on my development box and in Azure.
APIM Tier is Developer
On that Function app, during Publish in Visual Studio I have reported that attempting to manage application settings before a publish fails and in trying to add a new one causes Visual Studio to unexpectedly close. Manage Application Settings on Publish Related, don't know.
Just a Ctrl + F5 solved the problem for me. Try it! ;)
I just ran into the same issue because I used Linux (Preview) instead of Windows. When I blew away the Function App and recreated a new one with Windows, my API Manager was able to create an API off it.
I have reproduce the same scenario. It is working for me. May I know, below details,
01.Hope you have tested your function and it is working fine.
02.What is the type of the function ? Hope that is "Http trigger" ?
03.What is you APIM tier ? (eg : development, basic etc.)
At this time the solution for me was to use Microsoft Edge instead of Chrome.
It seems Microsoft Azure portal is not working properly in Chrome and I noticed issues in several places. Parts of pages are not rendered at all and sometimes even errors like this pop up just because of the browser.
I had this same problem.
The fix was both simple and unexpected.
When importing the function app, simply enter "/" in the API URL Suffix field.
For me this changed the BaseURL field value. Originally it was just the host, ie http://hostname/. It then appended the endpoint the hostname, http://hostname/endpoint
This is done on the "Create Function from App" modal.
I had the same problem when trying to publish my Azure Functions application with several HTTP triggered functions through API Management running on Consumption plan. The plan did not have anything to do with the problem though.
What I did not realize was that my function app was not working properly when browsing it from the Azure portal. I had some configuration errors that prevented the app to work properly. When I resolved those, I succeeded to publish the application through APIM.
So, check that your application is working properly by browsing to it if you run into the problem described in this thread.
I had temporarily suspended (or stopped) my Function App. Restarting it resolved the problem.
I hope Azure could improve the error message, at least from UX perspective.
The issue was that the function did not actually work.
The Browse button that redirects to the page with the light bulb and the text Your function app version X is up and running did show, but the function still didn't work.
The function error had to be fixed before when importing to the APIM was done.

Force "Add to homescreen" prompt a second time on chrome

I am trying to build a PWA. I managed to trigger the prompt a first time and installed the app on my shell (desktop). I then deleted it and I would like to force the prompt to reappear (for debug purpose) but it won't.
I set my chome flag Bypass user engagement checks to enabled, but there's still nothing I can do to trigger the prompt.
When I click on the console setting Application>Manifest>Add to homescreen, nothing happens and I don't receive any error message either.
It's exactly the same code that worked the first time. I just want to trigger it again now that the desktop shortcut has been deleted.
Also struggled with this issue.
At last found that going to chrome://apps/ and removing the app will enable to re-add it
If the chrome://flags/#bypass-app-banner-engagement-checks flag is enabled and you are still not getting the banner, its high likely one of PWA criteria is not met anymore.
It might have worked before. But with the changing code, something might have went wrong with Service worker, accessing via HTTP instead of HTTPS or having an invalid certificate kind if issues might have made your app not eligible for App install banner.
Validate: Validate your current sites PWA eligibility using Chrome Developer tools -> Audits -> Perform Audit -> Progressive Web App. See if all goes through regarding PWA criteria and if you see all looks good and still you don't get the Install Banner, post the Audit screenshot to give us some idea on whats going on.
You can just also just set it in the Developer Tools under Application by checking on Update on reload or click on Unregister to completely remove the SW. Dirty, but does the trick all the time.

Google Chrome Client Certificate Popup

I'm implementing a mutual authentication for my client in order to solve not having to continually whitelist some of the agencies with a dynamic ip. The process works fine in all browsers that I've tried in the Windows environment (Windows 7).
The problem is that there is a popup for every time that the user goes to the site. On most browsers, this is a one time occurrence, when you first go to the site for the day. On Google Chrome, however, the popup occurs on what appears to be every POST/GET request. I found how to disable the popup for IE and FF with this link: http://docs.threerings.org.uk/wiki/Certificates_without_prompting, but there is still the problem with Chrome.
I've tried to install the certificate into the Trusted Root Certification Authorities, but I get an error message, "The import failed because the store was read-only, the store was full, or the store did not open correctly.".
If anyone has an idea on what I can do to get around the pop-up for Chrome, it would be greatly appreciated.
This is what you're looking for:
http://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls
I could tell you how to do it exactly, but my honest opinion is that this is something you have to work out yourself. You need to know what is going on because you are more than likely to run into bugs (not bugs per-se but some undesired or unwanted results).
I have to admit that Google Chrome and Chromium are great browsers, but when it comes to client certificates, they have a lot of improvements to be made.
Just some extra info on this that may help people.
The first part references the CFBundleIdentifier which you can find in the Contents folder then info.plist. Click you Application and then show package contents then you should see it.
So I had to do this for Chromium for Tizen debugging below worked obviously use your CN name.
defaults write org.chromium.Chromium AutoSelectCertificateForUrls -array-add -string '{"pattern":"*","filter":{"ISSUER":{"CN":"Entrust Certification Authority"}}}'