Issues with default outputting of specific sites
EricFai opened this issue · 5 comments
I was trying to use this on www.puredevelopment.com and it throws an error. I tried it on a separate site and it worked fine. I then started digging and found that if I got to /lib/output.js and comment out opportunities(lighthouseResults) [line 106] it works fine for me.
Here is the error that I got
(node:9032) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined
at rules.filter.rule (C:\Users\eric\Documents\Projects\2020\ferg-psi-action\node_modules\psi\lib\output.js:73:20)
at Array.filter (<anonymous>)
at opportunities (C:\Users\eric\Documents\Projects\2020\ferg-psi-action\node_modules\psi\lib\output.js:71:34)
at Promise.resolve.then (C:\Users\eric\Documents\Projects\2020\ferg-psi-action\node_modules\psi\lib\output.js:106:7)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:9032) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9032) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hi @EricFai you are right. It seems that the rule uses-rel-preconnect
has no a details
property. I don't know if this is how the page speed api is designed. I mean, I don't know if should return an object whit a details
property as object which contains a type
.
Reading the documentation (check the example) I have found this:
"uses-rel-preconnect": {
"id": "uses-rel-preconnect",
"title": "Preconnect to required origins",
"description": "Consider adding preconnect or dns-prefetch resource hints to establish early connections to important third-party origins. [Learn more](https://developers.google.com/web/fundamentals/performance/resource-prioritization#preconnect).",
"score": 1.0,
"scoreDisplayMode": "numeric",
"details": {
"headings": [],
"type": "opportunity",
"items": [],
"overallSavingsMs": 0.0
}
},
so it seems that uses-rel-preconnect
should contains a details
object with the type
property. But I don't know if always will return this object.
Maybe @exterkamp can help and give us more information about it.
@exterkamp do you know if details
object have always a type
property? If not I could do a quick fix.
Best regards.
Looking at uses-rel-preconnect
there is a short circuit when there are >= 2 links (as there are with www.puredevelopment.com) which cuts the details out entirely.
details
shouldn't be relied on though, so we should harden our code to not die when there aren't details
in an audit.
Perhaps just add a !!details
check in output.js?
Many thanks for the info @exterkamp and good idea.
I'm going to do a PR with the correction, ok?
Best regards.
Update
👉 PR to fix the issue
This is happening for me as well, on version 4.0.1. I just started using psi
today, so I've no context on whether it was working previously. Ran psi https://puredevelopment.com
to confirm, and received the error.
Same here @crstauf.
Running both npx psi https://puredevelopment.com
and npx GoogleChromeLabs/psi https://puredevelopment.com
yield the same error output of TypeError: Cannot read property 'metrics' of undefined
; I'm seeing the same behavior for other sites. IMO this issue should be reopened.