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

misc(runner): add assertion for devtoolsLog as requiredArtifact #9290

Merged
merged 2 commits into from Jun 27, 2019

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented Jun 27, 2019

when we're checking required artifacts before running an audit, we assert that the default trace exists if the audit needs a trace, but we only assert that the top-level devtoolsLogs artifact exists (it always does since it's a base artifact), not if any logs on it exist (they might not if there was a pageLoadError).

As a result, while nearly everyone in an error report will have "Required {Artifact} gatherer did not run." error string, a few audits that rely only on the devtoolsLog will have the lovely "Cannot read property 'forEach' of undefined" error string instead.

This adds a check for devtoolsLog just like the trace check.

@@ -289,11 +289,13 @@ class Runner {
for (const artifactName of audit.meta.requiredArtifacts) {
const noArtifact = artifacts[artifactName] === undefined;

// If trace required, check that DEFAULT_PASS trace exists.
// TODO: need pass-specific check of networkRecords and traces.
Copy link
Member Author

Choose a reason for hiding this comment

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

networkRecords! This is old :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM

consistency with our trace check sgtm!

@@ -289,11 +289,13 @@ class Runner {
for (const artifactName of audit.meta.requiredArtifacts) {
const noArtifact = artifacts[artifactName] === undefined;

// If trace required, check that DEFAULT_PASS trace exists.
// TODO: need pass-specific check of networkRecords and traces.
const noTrace = artifactName === 'traces' && !artifacts.traces[Audit.DEFAULT_PASS];
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm I wasn't even aware we did this, I guess it's impossible to eliminate the defaultPass then even with a custom config if you want any network or trace data?

// TODO: need pass-specific check of networkRecords and traces.
const noTrace = artifactName === 'traces' && !artifacts.traces[Audit.DEFAULT_PASS];
// If trace/devtoolsLog required, check that DEFAULT_PASS trace/devtoolsLog exists.
// TODO: need pass-specific check of traces and devtoolsLogs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would personally just get rid of this TODO, are we really going to move to requiredArtifacts: ['traces.mySpecialPass'] at any point in the near future?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would personally just get rid of this TODO, are we really going to move to requiredArtifacts: ['traces.mySpecialPass'] at any point in the near future?

I think we're going to run into this sooner or later for the custom config/plugin reason you mention above. I think there are solutions, e.g. we could use a tracePassName (or whatever) convention in the audit options that defaults to defaultPass and check based on that here. That has its own pretty serious issues (we need to check requiredArtifacts and audit options now? what if an audit doesn't want to/can't follow the convention? etc), but I'd like to keep thinking about it.

Main thing is that if/when that situation does come up, this is where the error will occur, so it would be good to have a comment on it. I can definitely make it not a TODO, though.

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

Successfully merging this pull request may close these issues.

None yet

3 participants