-
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: handle invalid network timing data #6780
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.
LGTM!
@@ -272,6 +272,9 @@ module.exports = class NetworkRequest { | |||
* @param {LH.Crdp.Network.ResourceTiming} timing | |||
*/ | |||
_recomputeTimesWithResourceTiming(timing) { | |||
// Don't recompute times if the data is invalid. RequestTime should always be a thread timestamp. | |||
// If we don't have receiveHeadersEnd, we really don't have more accurate data. | |||
if (timing.requestTime === 0 || timing.receiveHeadersEnd === -1) return; |
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.
ha, I believe this would have saved me a lot of time figuring out how to generate the right network request events in #6171
@@ -269,8 +269,11 @@ class PageDependencyGraph { | |||
const networkNodeOutput = PageDependencyGraph.getNetworkNodeOutput(networkRecords); | |||
const cpuNodes = PageDependencyGraph.getCPUNodes(traceOfTab); | |||
|
|||
const rootRequest = networkRecords.reduce((min, r) => (min.startTime < r.startTime ? min : r)); | |||
// The root request is the earliest network request, using position in networkRecords array to break ties. |
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.
best comment
@@ -269,8 +269,11 @@ class PageDependencyGraph { | |||
const networkNodeOutput = PageDependencyGraph.getNetworkNodeOutput(networkRecords); | |||
const cpuNodes = PageDependencyGraph.getCPUNodes(traceOfTab); | |||
|
|||
const rootRequest = networkRecords.reduce((min, r) => (min.startTime < r.startTime ? min : r)); | |||
// The root request is the earliest network request, using position in networkRecords array to break ties. | |||
const rootRequest = networkRecords.reduce((min, r) => (r.startTime < min.startTime ? r : min)); |
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.
might be overkill, but should we pull this out into another method on NetworkAnalyzer
like findMainDocument
? I can see it usable by others (if they remember it's there).
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'd want to shift consumers to be using the graph as the source of truth, so hopefully no one else needs to compute this too? :)
Summary
In LR, the
timing
object can be defined but have no valid data (requestTime: 0, receiveHeadersEnd: -1
). This was unexpected and was causing problems later on down the chain for lantern.Masking the problem was the fact that the
rootNode
of the lantern graph was trying to pick the earliest network request but was breaking ties by choosing the last network record in the array. When the requestTimes were0
, it just ended up picking the last one and losing the real root node. This PR also adds some sanity checks around that to make sure we'd fail earlier about those unexpected cases.Related Issues/PRs
fixes #6378