Skip to content
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(main-resource): adjust main resource identification logic #4475

Merged
merged 4 commits into from
Feb 15, 2018

Conversation

kdzwinel
Copy link
Collaborator

@kdzwinel kdzwinel commented Feb 8, 2018

this PR aligns main-resource gatherer logic with final URL logic from driver.js

// Update startingUrl if it's ever redirected.
this._monitoredUrl = startingUrl;
this._networkStatusMonitor.on('requestloaded', redirectRequest => {
// Ignore if this is not a redirected request.
if (!redirectRequest.redirectSource) {
return;
}
const earlierRequest = redirectRequest.redirectSource;
if (earlierRequest.url === this._monitoredUrl) {
this._monitoredUrl = redirectRequest.url;
}
});

Fixes #4454
Fixes #4440

@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Feb 8, 2018

@patrickhulce @paulirish PTAL

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @kdzwinel I had my review sitting here and never hit submit!! Thoughts below

I think ideally we'd have a single source of truth for the final URL rather than duplicate copies of the logic, even if it is pretty small

Which of the following sounds best to folks

  • Change the computed artifact to accept the final URL/requestId as input, and find the correct network record that way
  • Change the driver code to just call this function to get the final URL instead of keeping track as we go
  • Add an assert to all usages of requestMainResource that it matches the URL artifact

@kdzwinel
Copy link
Collaborator Author

@patrickhulce no worries! Reusing URL.finalURL makes much more sense, not sure how I missed that. I went ahead and updated the code. PTAL

@@ -16,7 +16,7 @@ module.exports = {
return Promise.resolve();
},
gotoURL() {
return Promise.resolve('https://example.com');
return Promise.resolve('https://www.reddit.com/r/nba');
Copy link
Collaborator Author

@kdzwinel kdzwinel Feb 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the correct URL for the ../fixtures/traces/progressive-app.json returned by the fake-driver

@@ -330,6 +330,9 @@ describe('Runner', () => {
],

artifacts: {
URL: {
finalUrl: 'https://www.reddit.com/r/nba',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical-request-chains now depends on URL via mainResource

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @kdzwinel!

@patrickhulce
Copy link
Collaborator

the appveyor failure is hopefully unrelated @kdzwinel ?

image

@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Feb 15, 2018

@patrickhulce fun bug alert!

Hm… It fails on AppVeyor but passes on Travis? Yesterday I couldn't reproduce it locally, but today I can?? It fails on master???

Mystery! So I started debugging and it looks like mainResource.responseHeaders suddenly misses one of the Link headers 🤔Someone messed with the static-server and commited a broken PR? Nope! It's Chrome:

DevTools in Chrome 63 (stable):
two-63

DevTools in Chrome 66 (one used for testing):
one-66

https://crbug.com/812592 ❤️

@patrickhulce
Copy link
Collaborator

awesome sleuthing and thanks for filing the crbug @kdzwinel!

@patrickhulce patrickhulce merged commit 2f807e0 into GoogleChrome:master Feb 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants