-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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(navigation-runner): only run getArtifact
phase once
#15827
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,32 +110,20 @@ async function _navigate(navigationContext) { | |
* @return {Promise<{devtoolsLog?: LH.DevtoolsLog, records?: Array<LH.Artifacts.NetworkRequest>, trace?: LH.Trace}>} | ||
*/ | ||
async function _collectDebugData(navigationContext, phaseState) { | ||
const devtoolsLogArtifactDefn = phaseState.artifactDefinitions.find( | ||
definition => definition.gatherer.instance.meta.symbol === DevtoolsLog.symbol | ||
); | ||
const traceArtifactDefn = phaseState.artifactDefinitions.find( | ||
definition => definition.gatherer.instance.meta.symbol === Trace.symbol | ||
); | ||
|
||
const artifactDefinitions = [devtoolsLogArtifactDefn, traceArtifactDefn].filter( | ||
/** | ||
* @param {LH.Config.AnyArtifactDefn | undefined} defn | ||
* @return {defn is LH.Config.AnyArtifactDefn} | ||
*/ | ||
defn => Boolean(defn) | ||
); | ||
if (!artifactDefinitions.length) return {}; | ||
|
||
await collectPhaseArtifacts({...phaseState, phase: 'getArtifact', artifactDefinitions}); | ||
const getArtifactState = phaseState.artifactState.getArtifact; | ||
let devtoolsLog; | ||
let trace; | ||
|
||
for (const definition of phaseState.artifactDefinitions) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this change from a I guess it got rid of the filter and is cleaner, jw. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's cleaner and made the type narrowing easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh! you did this b/c need to narrow types to use getDebugData |
||
const {instance} = definition.gatherer; | ||
if (instance instanceof DevtoolsLog) { | ||
devtoolsLog = instance.getDebugData(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but... why not just getArtifact() ? types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to separate the It's really just defensive coding to prevent future regressions if the impl of dtlog/trace change. |
||
} else if (instance instanceof Trace) { | ||
trace = instance.getDebugData(); | ||
} | ||
} | ||
|
||
const devtoolsLogArtifactId = devtoolsLogArtifactDefn?.id; | ||
const devtoolsLog = devtoolsLogArtifactId && (await getArtifactState[devtoolsLogArtifactId]); | ||
const records = devtoolsLog && (await NetworkRecords.request(devtoolsLog, navigationContext)); | ||
|
||
const traceArtifactId = traceArtifactDefn?.id; | ||
const trace = traceArtifactId && (await getArtifactState[traceArtifactId]); | ||
|
||
return {devtoolsLog, records, trace}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh boy this is a pleasant diff to witness :)