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

Remove recordNetwork #2102

Merged
merged 7 commits into from
May 1, 2017
Merged

Remove recordNetwork #2102

merged 7 commits into from
May 1, 2017

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Apr 29, 2017

Now, we always actually record it. (And it's separated from recordTrace)

This flag was differentiating on if we expose it to gatherers and artifacts objects.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

const passName = pass.passName || Audit.DEFAULT_PASS;
if (usedNames.has(passName)) {
log.warn('config', `passes[${index}] may overwrite trace or network ` +
`data of earlier pass without a unique passName (repeated name: ${passName}.`);
log.warn('config', `passes[${index}] may overwrite trace ` +
Copy link
Member

@brendankenny brendankenny Apr 29, 2017

Choose a reason for hiding this comment

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

may overwrite data since it still could overwrite network records?

We should probably throw here instead of warning as there's no "may" about it anymore for network records. Can just be Passes must have unique names (repeated name: ${passName}). or something?

@@ -129,17 +129,13 @@ function validatePasses(passes, audits, rootPath) {
});
});

// Log if multiple passes require trace or network recording and could overwrite one another.
// Passes should have unique passName's. Warn otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

drop apostrophe

Copy link
Member

Choose a reason for hiding this comment

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

I guess that's hard to differentiate in a comment :)
// Passes should have unique `passName`s. Warn otherwise.?
// Passes should all have a unique passName. Warn otherwise.?


// Network records only given to gatherers if requested by config.
config.recordNetwork && (passData.networkRecords = networkRecords);
// expose devtoolsLog & networkRecords to gatherers
Copy link
Member

Choose a reason for hiding this comment

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

capital E

Copy link
Member

Choose a reason for hiding this comment

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

there's also a // Network is always recorded for internal use, even if not saved as artifact. comment that needs updating

// Network records only given to gatherers if requested by config.
config.recordNetwork && (passData.networkRecords = networkRecords);
// expose devtoolsLog & networkRecords to gatherers
passData.devtoolsLog = driver.devtoolsLog;
Copy link
Member

Choose a reason for hiding this comment

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

this is already handled above in config.recordTrace block

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch. devtoolsLog should never be within a recordTrace conditional.

config.recordNetwork &&
(tracingData.networkRecords[passName] = passData.networkRecords);

tracingData.devtoolsLogs[passName] = passData.devtoolsLog;
Copy link
Member

Choose a reason for hiding this comment

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

this has the same problem as #2062 in that there's no passData.devtoolLog if there was no trace. Leave inside the conditional until that's fixed?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixing that in this PR now. :)

(tracingData.networkRecords[passName] = passData.networkRecords);

tracingData.devtoolsLogs[passName] = passData.devtoolsLog;
tracingData.networkRecords[passName] = passData.networkRecords;
Copy link
Member

Choose a reason for hiding this comment

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

// If requested by config comment above needs update

@brendankenny
Copy link
Member

test errors are from not all passes having names in smokehouse's pwa-config.js so network records are overwriting each other. So, probably 👍 to throw in config.js to catch that early

@paulirish
Copy link
Member Author

PTAL

.then(_ => driver.beginNetworkCollect(options))
.then(_ => driver.beginDevtoolsLog())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should we do this the other way around? feasibly there could be some network request recorded before the devtools log start I guess, idk

@patrickhulce
Copy link
Collaborator

love it

@paulirish
Copy link
Member Author

@brendankenny this work for you?

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

I have a proposal for simplifying things a bit more. I'll make a PR on top of this :)

const passName = pass.passName || Audit.DEFAULT_PASS;
if (usedNames.has(passName)) {
log.warn('config', `passes[${index}] may overwrite trace or network ` +
`data of earlier pass without a unique passName (repeated name: ${passName}.`);
throw new Error(`Passes must have unique names (repeated passName: ${passName}.`);
Copy link
Member

Choose a reason for hiding this comment

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

hmm, this will still be confusing when a config doesn't include any pass names ("(repeated passName: defaultPass."). I don't know if there's a super clean solution (like the use of a Set here) if we want to still support one unnamed pass defaulting to defaultPass.

We could drop that, though, since it's a little confusing with the new world of always recording devtoolsLog, and this check could have two checked errors: no pass name and repeated pass names.

}

endDevtoolsLog() {
this._devtoolsLog.endRecording();
Copy link
Member

Choose a reason for hiding this comment

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

should this return the log like endTrace and endNetworkCollect instead of having GatherRunner call the getter directly?

Copy link
Member

Choose a reason for hiding this comment

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

And actually, should it return a promise? Kind of silly to wrap in yet another promise (less silly when we get async/await tho), but I was noticing the other day that endNetworkCollect is also wrapped in a promise despite being sync...presumably to keep the API easy to reason about.

Just bringing up the idea, not sure how I feel about that :)

.then(_ => driver.beginNetworkCollect(options))
.then(_ => driver.beginDevtoolsLog())
Copy link
Member

Choose a reason for hiding this comment

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

need to update outline at top of file

@@ -238,20 +239,20 @@ class GatherRunner {
// an object with a traceEvents property. Normalize to object form.
passData.trace = Array.isArray(traceContents) ?
{traceEvents: traceContents} : traceContents;
passData.devtoolsLog = driver.devtoolsLog;
log.verbose('statusEnd', 'Retrieving trace');
});
}

const status = 'Retrieving network records';
Copy link
Member

Choose a reason for hiding this comment

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

update status message?

@brendankenny
Copy link
Member

I'll make a PR on top of this :)

actually, no I won't :) I really need #2062 to do it cleanly.

Speaking of which, what do you think about reverting the last commit? It should really be in #2062 anyways...this PR can get by pretty easily without touching devtoolsLog and #2062 is already touching it, so it makes a lot more sense over there

@brendankenny
Copy link
Member

(or just merge them together or whatever if this is getting crazy since they're both mostly reviewed)

@brendankenny
Copy link
Member

OK, removed devtoolsLog stuff and added a special warning for multiple unnamed passes (so you wouldn't get a warning about repeated passName 'defaultPass' even though you never named any of your passes 'defaultPass). I didn't remove defaultPass though because that's a lot more work in a lot more places and not worth it right now :)

@paulirish
Copy link
Member Author

yup. this WFM.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

waiting for travis...

@brendankenny brendankenny merged commit 07e0aab into master May 1, 2017
@brendankenny brendankenny deleted the killrecordnetwork-master branch May 1, 2017 22:29
paulirish added a commit to paulirish/lighthouse that referenced this pull request May 5, 2017
* always record network and save in artifacts
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.

3 participants