-
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(driver): warn about remaining inflight requests urls #14963
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
69a7d30
to
36f79ca
Compare
@@ -487,6 +487,18 @@ async function waitForFullyLoaded(session, networkMonitor, options) { | |||
throw new LighthouseError(LighthouseError.errors.PAGE_HUNG); | |||
} | |||
|
|||
// Log remaining inflight requests if any. | |||
const inflightRequestsUrl = networkMonitor |
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.
inflightRequestUrls
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.
Updated
if (inflightRequestsUrl.length > 0) { | ||
log.warn( | ||
"waitFor", | ||
"Remaining inflight requests URLs", |
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.
"Remaining inflight requests URLs", | |
"Remaining inflight requests", |
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.
This line could be really long if there are multiple requests, maybe we should have each request on its own line.
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.
Hey @connorjclark and @adamraine
Thanks for the feedback 💪
From my point of view as long as it's an array that common console/terminal formatters can handle then it should be fine. But maybe you'd like me to add something along the lines of show first 5 requests and after that ...and X more requests
for example? That way it should be pretty neat in case of a lot of remaining inflight requests🤔
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.
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.
@connorjclark Thanks for checking this 💪
My preference is to join the urls using
,
, and keeping it to a single warn message.
Do you mean like you posted on your screenshot or inflightRequestsUrl.join(',')
? I would prefer the first option so the way you posted it on your screenshot 🤔
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.
inflightRequestsUrl.join(', ')
. There shouldn't be on the order of hundreds (or even dozens...) of in flight requests, so I don't think we'd ever even see this log message being elided.
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.
If you'd prefer that then sure, but what do you think about just keeping inflightRequestsUrl
and let the terminals (or wherever the logs are) to handle the formatting? Seems more safe than joining with ,
🤔
But if you'd heavily prefer inflightRequestsUrl.join(', ')
then just let me know and I'll change it to that and we can proceed 😁
Thank you for the review btw 💪
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.
bump
@adamraine & @connorjclark let me know please :D
dde40d4
to
28da280
Compare
28da280
to
ebb6cc3
Compare
ebb6cc3
to
fdd0c53
Compare
@@ -63,7 +63,7 @@ describe('waitForFullyLoaded()', () => { | |||
|
|||
beforeEach(() => { | |||
session = {sendCommand: fnAny().mockResolvedValue(), setNextProtocolTimeout: fnAny()}; | |||
networkMonitor = {}; | |||
networkMonitor = {getInflightRequests: fnAny().mockReturnValue([])}; | |||
|
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.
What's the recommended approach to mocking log
to test if it has been called correctly? I found importMock
, but it doesn't seem to support mocking external modules.
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.
log.events
will emit events when something is logged (edit, well, log.warn
ed, at least), so you can collect those events and assert those without mocking. One example:
lighthouse/core/test/config/filters-test.js
Lines 471 to 482 in 2b8caf2
/** @type {Array<unknown>} */ | |
const warnings = []; | |
/** @param {unknown} evt */ | |
const saveWarning = evt => warnings.push(evt); | |
log.events.on('warning', saveWarning); | |
const filtered = filters.filterConfigByExplicitFilters(resolvedConfig, { | |
onlyAudits: null, | |
onlyCategories: ['timespan', 'thisIsNotACategory'], | |
skipAudits: null, | |
}); | |
log.events.off('warning', saveWarning); |
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.
Let me know if the test is fine or you would like something more and I'll add it :D
codecov
seems to be complaining for some reason though as if it didn't catch the test :/
fdd0c53
to
831bb1b
Compare
831bb1b
to
c8a40f4
Compare
c8a40f4
to
a24f19d
Compare
Summary
Add extra warning to show inflight requests if the load timeout is reached.
The reason of this small and simple change is to give the user a better logging experience to know what's wrong.