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

Issues with default outputting of specific sites #115

Closed
EricFai opened this issue Sep 1, 2020 · 5 comments · Fixed by #116
Closed

Issues with default outputting of specific sites #115

EricFai opened this issue Sep 1, 2020 · 5 comments · Fixed by #116

Comments

@EricFai
Copy link

EricFai commented Sep 1, 2020

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.
@JuanMaRuiz
Copy link
Contributor

JuanMaRuiz commented Sep 2, 2020

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.

@exterkamp
Copy link
Collaborator

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?

@JuanMaRuiz
Copy link
Contributor

JuanMaRuiz commented Sep 3, 2020

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

@crstauf
Copy link

crstauf commented Nov 9, 2020

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.

@edm00se
Copy link

edm00se commented Dec 17, 2020

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.

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

Successfully merging a pull request may close this issue.

5 participants