-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
for (const definition of phaseState.artifactDefinitions) { | ||
const {instance} = definition.gatherer; | ||
if (instance instanceof DevtoolsLog) { | ||
devtoolsLog = instance.getDebugData(); |
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.
but... why not just getArtifact() ? types?
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.
I want to separate the getArtifact
logic from the getDebugInfo
logic even if they happen to be the same. Right now when designing gatherers we assume that getArtifact
is only run once at the end of gathering. If we were to just reuse getArtifact
here, it would break that assumption.
It's really just defensive coding to prevent future regressions if the impl of dtlog/trace 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( |
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 :)
let devtoolsLog; | ||
let trace; | ||
|
||
for (const definition of phaseState.artifactDefinitions) { |
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.
Did this change from a .find
to a loop for some reason, or just preference?
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 comment
The 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 comment
The 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
@connorjclark noticed that we are running the
getArtifact
phase of the DT log and trace twice during a normal navigation run:The root cause is that we attempt to get a preview of the
DevtoolsLog
andTrace
artifacts before running through thegetArtifact
phase properly. This doesn't actually cause any problems because thegetArtifact
implementation is idempotent in both cases. However this could theoretically cause problems if that were to change down the line.This PR adds a separate path for the navigation runner to get it's preview of the DT log and trace so that making changes to
getArtifact
is safer.