Closed mzkmzk closed 7 years ago
@mzkmzk does the audit show an error or still produce results? (you'd be looking for a performance opportunity with a red error message)
Right now we do some feature detection and have a fallback path if that command fails, so the message itself in the logs should not be a concern. By the way, I noticed your running it with headless so be warned that the savings reported will be understated since throttling is not supported! See the docs for more.
ok, thanks!
I tried the code: https://github.com/GoogleChrome/lighthouse/blob/master/docs/headless-chrome.md#node.
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
function launchChromeAndRunLighthouse(url, flags = {}, config = null) {
return chromeLauncher.launch(flags).then(chrome => {
flags.port = chrome.port;
return lighthouse(url, flags, config).then(results =>
chrome.kill().then(() => results));
});
}
const flags = {
chromeFlags: ['--headless']
};
launchChromeAndRunLighthouse('http://act.vip.xunlei.com/pc/kn/2017/wky/index.html', flags).then(results => {
results.artifacts = 'ignore'
results.reportCategories = 'ignore '
console.log(JSON.stringify(results, null, 4))
});
Run the code three times, the results obtained here
First , this error has appeared three times,
"consistently-interactive": {
"score": null,
"displayValue": "",
"rawValue": null,
"error": true,
"debugString": "Audit error: Main thread activity continued through the end of the trace recording. Consistently Interactive requires a minimum of 5 seconds of both main thread idle and network idle.",
...
},
however, other errors of first-interactive、consistently-interactive、offscreen-images and load-fast-enough-for-pwa appeared in the third time.
"first-interactive": {
....
"error": true,
"debugString": "Audit error: The main thread was busy for the entire trace recording. First Interactive requires the main thread to be idle for several seconds.",
...
}
"consistently-interactive": {
...
"error": true,
"debugString": "Audit error: Main thread activity continued through the end of the trace recording. Consistently Interactive requires a minimum of 5 seconds of both main thread idle and network idle.",
...
}
"offscreen-images": {
...
"error": true,
"debugString": "Audit error: The main thread was busy for the entire trace recording. First Interactive requires the main thread to be idle for several seconds.",
...
}
"load-fast-enough-for-pwa": {
...
"error": true,
"debugString": "Audit error: The main thread was busy for the entire trace recording. First Interactive requires the main thread to be idle for several seconds.",
...
}
Is my CPU the worst?
> lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Stepping: 4
CPU MHz: 2600.092
BogoMIPS: 5200.18
Hypervisor vendor: Xen
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0
We're working on improving our error messages here to be clearer, but that error message you receive isn't a Lighthouse error, it just means that the page you audited was running lots of JavaScript and didn't quiet down within our time limit. You can try to raise the time limit via the flag maxWaitForLoad
. You can also try another simpler page like example.com
to make sure your setup is working first.
Oh, you’re right. I tried https://example.com
, the report of running was normal. It proved that the lighthouse of my machine could analyze the simple webpage. However, the maxWaitForLoad settings were not seem to work, and I still received similar error messages when I raised the time limit to 60s via the flag maxWaitForLoad.
"script-blocking-first-paint": {
...
"error": true,
"debugString": "Audit error: Required TagsBlockingFirstPaint gatherer encountered an error: The asynchronous expression exceeded the allotted time of 60s",
...
Should I upgrade my computer configuration?Or should I continue arise the time limit via the flag maxWaitForLoad?
The following is my demo code:
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const config = require('./lighthouse.config.js');
function launchChromeAndRunLighthouse(url, flags = {}, config = null) {
return chromeLauncher.launch(flags).then(chrome => {
flags.port = chrome.port;
return lighthouse(url, flags, config).then(results =>
chrome.kill().then(() => results));
});
}
const flags = {
chromeFlags: ['--headless'],
maxWaitForLoad: 1000 * 60
};
launchChromeAndRunLighthouse('http://act.vip.xunlei.com/pc/kn/2017/wky/index.html', flags, config).then(results => {
results.artifacts = 'ignore'
results.reportCategories = 'ignore '
console.log(JSON.stringify(results, null, 4))
});
Strange, I'm experiencing intermittent failures of that page to load, but I'm unable to reproduce when the page loads successfully. The error you're experiencing would typically suggest either
Since I'm unable to reproduce with the page when it loads, and it looks like you're running in a server environment, neither of these seem to apply. My last remaining thoughts are that it might be something headless related. Have you tried auditing this page without the --headless
flag using xvfb or something similar?
Thank you for your suggestions, I think the most fundamental reason probably is my low server configuration. The problem may be solved when I upgrade my server configuration. Thank you for your help within this week.
How do I run the file??????
Please open a new issue for your new problem.
I encountered some problems when using lighthouse at ubuntu14.04
eg:
method <= browser ERR:error Audits.getEncodedResponse +75ms
andmethod <= browser ERR:error Network.getResponseBody +10ms
Linux OS
node version
chrome
lighthouse:
but run it's has some error
Lighthouse does not seem to get the contents of the response so that a similar
method <= browser ERR: error Audits.getEncodedResponse
this error