-
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(start-url): stay offline for entirety of offlinePass #9451
Conversation
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.
nice catch. Ugh this gatherer just won't ever be happy :)
@@ -77,7 +93,7 @@ class StartUrl extends Gatherer { | |||
if (!response.fromServiceWorker) { | |||
return resolve({ | |||
statusCode: -1, | |||
explanation: 'Unable to fetch start URL via service worker.', | |||
explanation: 'Fetched start URL but not via service worker.', |
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 seems like this message is more confusing than the original (should this audit care about that it's fetchable like that?)
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.
Right now the message is indistinguishable from not being able to fetch it at all which is a problem IMO. The fact that it fetched but was falling back to disk cache or something is worth flagging. Totally up for whatever wording others feel captures this goal.
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 start URL did respond, but not via a service worker
mostly trying to align with the text of the audit.. (where we dont talk about fetching, etc)
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 fact that it fetched but was falling back to disk cache or something is worth flagging
I don't know if everyone knows the priority order here, though. If I'm looking at the start_url
audit LH tells me
The start URL did respond, but not via a service worker
my first question would be "well why didn't LH try fetching via the SW? Do I need to force it somehow?"
It seems like the only important information is that LH tried to fetch it and the SW didn't return it. Just because it was in the disk cache during the LH run doesn't mean it will be for returning users, and isn't that the case we're testing for?
Alternatively, should we just call out the fromDiskCache
case with a separate explanation?
const navigationRecord = loadData.networkRecords.filter(record => { | ||
return URL.equalWithExcludedFragments(record.url, passContext.url) && | ||
record.fetchedViaServiceWorker; | ||
}).pop(); // Take the last record that matches. | ||
|
||
return passContext.driver.goOnline(passContext) |
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.
can you add a comment around L16 that the goOnline now happens in start-url which sequentially follows this gatherer?
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.
actually it seems like the goOffline in L16 isnt needed anymore since starturl does it on its own. right
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.
can you add a comment around L16 that the goOnline now happens in start-url which sequentially follows this gatherer?
well the goOnline
that cleans this up actually happens in gather-runner
that was the problem. each afterPass
happens while online and each gatherer has to handle its own online/offline cycle. but yes comment is great idea 👍
actually it seems like the goOffline in L16 isnt needed anymore since starturl does it on its own. right
it's still needed to setup the offline for the load of the page, we do the offline check for both the page and the start url separately
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.
nit on wording otherwise lgtm
@@ -77,7 +93,7 @@ class StartUrl extends Gatherer { | |||
if (!response.fromServiceWorker) { | |||
return resolve({ | |||
statusCode: -1, | |||
explanation: 'Unable to fetch start URL via service worker.', | |||
explanation: 'Fetched start URL but not via service worker.', |
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 start URL did respond, but not via a service worker
mostly trying to align with the text of the audit.. (where we dont talk about fetching, etc)
evaluateAsync: unimplemented, | ||
on: unimplemented, | ||
off: unimplemented, | ||
}; |
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.
moving off bespoke mocks is good, but I have to say this is a nice model for this file :)
assert.equal(artifactWithFragment.statusCode, 200); | ||
const result = await gatherer.afterPass(passContext); | ||
expect(mockDriver.goOffline).toHaveBeenCalled(); | ||
expect(mockDriver.goOnline).toHaveBeenCalled(); |
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 do you think about an extra level of checking for these that it was offline when evaluateAsync
was called, not just that off and on were both called?
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 it as a separate test but not on every single one :) done!
Summary
tl;dr -
StartUrl
gatherer is not actually offline while it is checking for service worker start URL fetching. This PR fixes that.In #6957, the start url gatherer was refactored to allow WebAppManifest to be part of core artifacts and avoid being double fetched. The code appeared to assume that the page was offline at the start of the
afterPass
because it went back online to fetch the manifest before going back offline. This wasn't actually the case though. Due to refactorings long ago in gather runner we actually always run the entirety ofafterPass
while online.For pages with service workers that are always controlling the page this doesn't end up making much of a difference because of good ol' #709. However, if the service worker only handles requests while the page is in an offline state (not really clear how one does this), then all requests actually go out over the network and we trip our
!response.fromServiceWorker
line to falsely fail the page (which is normally a good thing because it means that all pages that didn't have a service worker didn't magically start passing when this bug was introduced! 😄)Related Issues/PRs
fixes #9450