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

fix: recover if protocol does not support CSS rule usage #1479

Merged
merged 3 commits into from
Jan 17, 2017

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Jan 17, 2017

R: @wardpeet all

fixes #1473

Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

What was the deal with @brendankenny's recoverable error stuff? Would that be a good fit?

@ebidel
Copy link
Contributor

ebidel commented Jan 17, 2017

#1482 :)

@@ -25,7 +25,8 @@ class CSSUsage extends Gatherer {
beforePass(options) {
return options.driver.sendCommand('DOM.enable')
.then(_ => options.driver.sendCommand('CSS.enable'))
.then(_ => options.driver.sendCommand('CSS.startRuleUsageTracking'));
.then(_ => options.driver.sendCommand('CSS.startRuleUsageTracking'))
.catch(_ => this.failure = 'CSS Usage tracking requires Chrome \u2265 56');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a TODO to remove this once m56 is released as stable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this marks all errors from beforePass as this error. To be fair, the previous code was anticipating no errors :) but probably better to check that it's 'CSS.startRuleUsageTracking' wasn't found or whatever so that other possible errors aren't muted

@brendankenny
Copy link
Member

recoverable errors will work, they're just a manual replacement for -1 right now since the last step of #941 isn't in place yet, so probably fine just to use -1 for now

@brendankenny
Copy link
Member

one interesting thing that this brings up that we didn't anticipate with a recoverable error is if beforePass throws a recoverable error afterPass is still called. The recoverable error will win and be the value of that artifact in that case, but I guess that means all audits where that's a danger will have to deal with it like this and have to keep internal state tracking that it failed, and not to do more stuff in afterPass? OTOH if we didn't call afterPass, the gatherer has no chance to clean up after itself, close domains, etc. Hopefully this isn't leading us to a finally callback or something...

@patrickhulce
Copy link
Collaborator Author

Interesting what's wrong with finally? I'm not opposed to a finally style pass since that would have simplified the domain disabling quite a bit IMO

@wardpeet
Copy link
Collaborator

wardpeet commented Jan 17, 2017

i'm ok with finally as well :) Seems a good idea to clean up all the things!
image

Is it an option for the future to change the output of the formatter? (if < chrome 56 show coming soon icon, ...) so it doesn't look like a failure.
Not needed for this PR.

@brendankenny brendankenny merged commit 777fa4f into master Jan 17, 2017
@brendankenny brendankenny deleted the warn_css_usage branch January 17, 2017 22:15
@brendankenny
Copy link
Member

what's wrong with finally?

in theory nothing, but we'd really have to nail down when it runs, its relation to the artifact produced, etc. e.g. will it always make sense to clean up after afterPass? What happens to errors in finally, do they replace the artifact with an error (like if there was an error in afterPass or do we rely on error reporting or whatever to catch those? etc

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 this pull request may close these issues.

Error: Protocol error (CSS.startRuleUsageTracking): 'CSS.startRuleUsageTracking' wasn't found
4 participants