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

core(tracehouse): allow missing FCP #9174

Merged
merged 6 commits into from
Jun 20, 2019
Merged

core(tracehouse): allow missing FCP #9174

merged 6 commits into from
Jun 20, 2019

Conversation

patrickhulce
Copy link
Collaborator

Summary
One of the only changes made to tracium that needs to be ported back, part of the larger plan specified in #8956.

Related Issues/PRs
#8956

@@ -43,7 +43,8 @@ class TraceOfTab {
* @return {Promise<LH.Artifacts.TraceOfTab>}
*/
static async compute_(trace) {
return LHTraceProcessor.computeTraceOfTab(trace);
const traceOfTab = await LHTraceProcessor.computeTraceOfTab(trace, {throwOnNoFCP: true});
return /** @type {LH.Artifacts.TraceOfTab} */ (traceOfTab);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I really don't like this, but I was blanking on a way to do this without casting and/or manually reconstructing the entire object.

any ideas @brendankenny ?

Copy link
Member

Choose a reason for hiding this comment

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

what if we didn't throw in trace-processor.js at all and only throw NO_FCP out here if it's not on the return value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't that involve manually reconstructing every object that has fcp?

Copy link
Member

Choose a reason for hiding this comment

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

doesn't that involve manually reconstructing every object that has fcp?

yeah, I can't think of a way around it, tsc won't track the validations on all three existence checks into the return value :/

It would allow simplifying trace-processor.js (no argument, no fcp check in there, etc), though, and it would keep the fcp checks and cast in the same place in this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, ended up not being so bad I guess. done!

@patrickhulce
Copy link
Collaborator Author

ping 🏓

@brendankenny
Copy link
Member

brendankenny commented Jun 20, 2019

remove no fcp test

because the computed artifact already has a test for this?

(I mean for overall testing, obviously the lib/ version doesn't need it anymore :)

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.

nice! last nits but LGTM

@@ -16,6 +16,9 @@
* 4. Return all those items in one handy bundle.
*/

/** @typedef {Omit<LH.Artifacts.TraceTimes, 'firstContentfulPaint'> & {firstContentfulPaint?: number}} TraceTimesWithoutFCP */
/** @typedef {Omit<LH.Artifacts.TraceOfTab, 'firstContentfulPaintEvt'|'timings'|'timestamps'> & {timings: TraceTimesWithoutFCP, timestamps: TraceTimesWithoutFCP, firstContentfulPaintEvt?: LH.Artifacts.TraceOfTab['firstContentfulPaintEvt']}} TraceOfTabWithoutFCP */
Copy link
Member

Choose a reason for hiding this comment

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

these types seem kind of terrible for downstream users, but I guess we can iterate on it in the future :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

heh, yeah there will be lots of interesting problems to solve when we expose these types :)

lighthouse-core/computed/trace-of-tab.js Outdated Show resolved Hide resolved
lighthouse-core/computed/trace-of-tab.js Show resolved Hide resolved
firstContentfulPaintEvt,
timings: {...timings, firstContentfulPaint: firstContentfulPaintTiming},
timestamps: {...timestamps, firstContentfulPaint: firstContentfulPaintTs},
};
Copy link
Member

Choose a reason for hiding this comment

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

ha, I don't entirely trust tsc with object spreading + composition, but any change I make here gives the right error, so good job compiler! (and @patrickhulce)

@patrickhulce
Copy link
Collaborator Author

because the computed artifact already has a test for this?

Yes, that commit just removed the test from trace-processor-test because we obviously don't need it anymore :)

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.

3 participants