-
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(runner): asset manager helper #13519
Conversation
if (runOpts.url && !URL.equalWithExcludedFragments(runOpts.url, requestedUrl)) { | ||
throw new Error('Cannot run audit mode on different URL'); | ||
} |
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.
Removing this check should be the only functional change to legacy mode. I didn't think it was needed because we can proceed with the requestedUrl
from the artifacts. I'd be open to adding this back as a non-fatal warning or something in a different location.
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.
The check makes more sense from the context of the CLI. Currently you can do -G
and then -A
separately but you must use the same URL, otherwise it errors because you probably made a mistake. Perhaps instead, we should have -A
mode only use what is saved in the gathering step–url, settings, etc. and throw if a url is also provided
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 would prefer just logging a warning, since we could just ignore the passed in URL.
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'm fine with just a warning. -G/A is pretty advanced usage so we don't really need these runtime failures to protect us, IMO
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.
A report warning, then, not logger. This will otherwise be ignored and is sure to mess me up eventually so a loud warning is necessary :)
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 would prefer switching to a fatal error in the CLI than that. We would need to send the warning message all the way down to Runner.run
where run warnings are collected. Removing URL checks from Runner.run
is part of the reason I created this PR.
The warning is quiet, but Lighthouse is still performing the more correct and expected operation IMO.
if (runOpts.url && !URL.equalWithExcludedFragments(runOpts.url, requestedUrl)) { | ||
throw new Error('Cannot run audit mode on different URL'); | ||
} |
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.
The check makes more sense from the context of the CLI. Currently you can do -G
and then -A
separately but you must use the same URL, otherwise it errors because you probably made a mistake. Perhaps instead, we should have -A
mode only use what is saved in the gathering step–url, settings, etc. and throw if a url is also provided
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.
Eliminates the url parameter for Runner.run. The URL should be passed into Runner.run as part of the gatherFn closure.
I didnt totally understand the motivation here.. but the user-triggered nav usecase is definitely different. still don't totally understand it... cuz there, we don't even have a requestedUrl at all.. but... that's why we have this new 'requestor' thing in 13496. makes sense.
if (runOpts.url && !URL.equalWithExcludedFragments(runOpts.url, requestedUrl)) { | ||
throw new Error('Cannot run audit mode on different URL'); | ||
} |
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'm fine with just a warning. -G/A is pretty advanced usage so we don't really need these runtime failures to protect us, IMO
Moving the URL tracking to the artifacts make sense, but can you explain what this enables? All those modes already call into The extracted code is also not independent of the other code in lighthouse/lighthouse-core/runner.js Lines 177 to 184 in a26c8ee
Part of what #12393 ran into in making an audit-runner is that there still needs to be a top-level orchestrator of some sort. We're always going to have UX niceties or issues with our conceptual model that will need to be handled somewhere and that prevent a pure functional artifacts -> audits -> LHR pipeline. Whether or not changing the URL for |
This PR is reorganizing for future work in #13364, handling the dependencies is a part of that future work. We can duplicate the catch block and put it inside
The goal of #13364 is not to get rid of the top-level orchestrator. The goal is to give the orchestrator some flexibility in when auditing and gathering happen so we can run gathering phases of all steps before running any auditing phases. |
I think I see where you're coming from now. IIUC:
Hence the new function. (the quoted statement above was a little confusing because a user flow won't be able to use FWIW, this PR may have benefited from being split up with one stone per bird :) Both URL normalization and artifact acquisition are fairly touchy pipelines, and Overall the change sounds good to me. I'm very excited about moving to a more explicit audit runner (#12393 🥲). I am a little concerned about the extra layers of test mocks (and intricacies of those mocks), but it does seem like a decent bit will be able to be removed as #13364 progresses? e.g. snapshot and timespan runners will be able ditch their mocked runners and only mock gathering, runner won't have to care about mocks at all anymore, etc |
reset, | ||
}; | ||
|
||
jest.mock('../../../runner.js', () => runnerModule); |
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.
these mock commands are tricky when it comes to es modules, b/c jest hoists them to the top to make them work. https://jestjs.io/docs/manual-mocks#using-with-es-module-imports
can keep it as-is since still commonjs, or just continue to do the jest.mock
at the toplevel but instead like
jest.mock('....', createRunnerModuleMock())
// not even sure if this expression with a function call can be hoisted by jest 👀
no preference atm.
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 like this way since it follows the format of mockDriverSubmodules
.
I don't know if #13364 will decrease the number of mocked modules, we might just change what's being mocked. Haven't investigated that much so we can cross that bridge later. |
@@ -10,6 +10,7 @@ | |||
*/ | |||
|
|||
const {Util} = require('../util-commonjs.js'); | |||
const LHError = require('../lib/lh-error.js'); |
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.
So turns out this creates a circular dependency that messes with our DT bundle. url-shim.js
might not be the best place for this @brendankenny.
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.
runner-helpers.js
maybe?
is it the |
looks like from here? lighthouse/build/build-bundle.js Lines 141 to 147 in da73d4a
substituting our class derived from the global |
lol: #5293 (review) |
#13545 to fix url shimming for good |
This PR kills two birds with one stone:
url
parameter forRunner.run
. The URL should be passed intoRunner.run
as part of thegatherFn
closure. This makes it easier to define a navigation runner that does not know the requested URL ahead of time core(fr): user triggered navigations #13496.Issues
#13364
#11313