Skip to content

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

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
Contributor

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
Contributor

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
Contributor

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
Contributor

@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

*/

/** @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
Contributor

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 :)

firstContentfulPaintEvt,
timings: {...timings, firstContentfulPaint: firstContentfulPaintTiming},
timestamps: {...timestamps, firstContentfulPaint: firstContentfulPaintTs},
};
Copy link
Contributor

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