-
Notifications
You must be signed in to change notification settings - Fork 133
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
Resource Timing integration #319
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.
It seems that the way this works out is that there's a report timing object created just before the load event is invoked, which seems good.
Note that the string formatting comment still stands I think. |
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.
Apologies for not updating this sooner. While reviewing this I ended up filing whatwg/fetch#1201, but forgot to write down the bits that didn't add up for me here.
xhr.bs
Outdated
@@ -1018,6 +1024,8 @@ return <a>this</a>'s <a>cross-origin credentials</a>. | |||
<ol> | |||
<li><p>Set <var>xhr</var>'s <a>state</a> to <i>done</i>. | |||
|
|||
<li><p><a for=/>Report timing</a> for <var>xhr</var>. |
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.
We report timings here, but two steps down we set response to a network error. Whereas above we don't report timing at all if response is a network error.
Now per whatwg/fetch#1202 maybe some network errors should get report timing, but I don't think the current setup makes that happen correctly, 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.
We always call "Report timing", and let FETCH decide if to report or not (if the response has a timing info
).
WDYM by "above we don't report timing at all if response is a network error", I think we do: if <var>xhr</var>'s <a for=XMLHttpRequest>response</a>'s is a <a for=/>network error</a>, run the <a>request error steps</a> for <var>xhr</var>
(request error steps would report the timing).
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.
Yeah, I think that's right. Let's solve whatwg/fetch#1215 before landing this then as currently finalize and report timing always returns early for network errors I just discovered.
I think it would also be good to ensure we have test coverage here. In the sense that the final readystatechange/load event has access to the RT entry.
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's solve whatwg/fetch#1215 before landing this then as currently finalize and report timing always returns early for network errors I just discovered.
whatwg/fetch#1311 addressed this.
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.
Added a requisite test here: web-platform-tests/wpt#31027
Also, report timing info for network errors for the fetch() APIs. The timing info attached to a network error is always "opaque", containing only start/end time and the original request URL. This change currently only applies to the fetch API, and should be applied to the different callers of FETCCH as part of [this](whatwg/html#6542) and [this](whatwg/xhr#319) work. Closes whatwg#1215
Also, report timing info for network errors for the fetch() APIs. The timing info attached to a network error is always "opaque", containing only start/end time and the original request URL. This change currently only applies to the fetch API, and should be applied to the different callers of FETCCH as part of [this](whatwg/html#6542) and [this](whatwg/xhr#319) work. Closes whatwg#1215
Test that: - A ResourceTiming entry is created for an XmlHttpRequest - The entry is available during load event handling - The entry's responseEnd time is not after the load event time - Entries are created for network errors (e.g. CORS fail, wrong scheme) See whatwg/xhr#319
* XHR ResourceTiming entry creation Test that: - A ResourceTiming entry is created for an XmlHttpRequest - The entry is available during load event handling - The entry's responseEnd time is not after the load event time - Entries are created for network errors (e.g. CORS fail, wrong scheme) See whatwg/xhr#319 * lint * Move xhr internals to resource-loaders
@annevk I think this should be OK now, in conjunction with the FETCH handling of network errors. |
…tonly Automatic update from web-platform-tests XHR ResourceTiming entry creation (#31027) * XHR ResourceTiming entry creation Test that: - A ResourceTiming entry is created for an XmlHttpRequest - The entry is available during load event handling - The entry's responseEnd time is not after the load event time - Entries are created for network errors (e.g. CORS fail, wrong scheme) See whatwg/xhr#319 * lint * Move xhr internals to resource-loaders -- wpt-commits: 167763f156d113e154cf35960741dc1876f556a8 wpt-pr: 31027
…tonly Automatic update from web-platform-tests XHR ResourceTiming entry creation (#31027) * XHR ResourceTiming entry creation Test that: - A ResourceTiming entry is created for an XmlHttpRequest - The entry is available during load event handling - The entry's responseEnd time is not after the load event time - Entries are created for network errors (e.g. CORS fail, wrong scheme) See whatwg/xhr#319 * lint * Move xhr internals to resource-loaders -- wpt-commits: 167763f156d113e154cf35960741dc1876f556a8 wpt-pr: 31027
* XHR ResourceTiming entry creation Test that: - A ResourceTiming entry is created for an XmlHttpRequest - The entry is available during load event handling - The entry's responseEnd time is not after the load event time - Entries are created for network errors (e.g. CORS fail, wrong scheme) See whatwg/xhr#319 * lint * Move xhr internals to resource-loaders
When response is a network error or body is fully read, finalize and report the response. Depends on whatwg/fetch#1185 See: w3c/resource-timing#261 and w3c/resource-timing#252
ab9b848
to
23490db
Compare
@annevk: revised to align with how FETCH handles network errors. |
@annevk this has been ready for a while for a review. Could you take a look when you get a chance? |
@@ -963,6 +967,8 @@ return <a>this</a>'s <a>cross-origin credentials</a>. | |||
<li><p>If <var>xhr</var>'s <a for=XMLHttpRequest>response</a> is a <a>network error</a>, then | |||
return. | |||
|
|||
<li><p><a for=/>Report timing</a> for <var>xhr</var>. |
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.
Could we move this to line 966, and avoid calling report timing from 2 different places?
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.
No, because handle errors
needs to report errors only in certain conditions + we need to report it if there are no errors. So there will always be two places
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 to me we could move this up if we make it conditional upon the timed out flag? (And in the future perhaps the timed out flag can be replaced by using an aborted network error.)
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.
Ah it wouldn't work because handle errors
is also called from processBodyError
, in which case the processEndOfBody
callback will not be reached at all. We've been through this in early iterations of this PR
When response is a network error or body is fully read,
finalize and report the response.
Depends on whatwg/fetch#1185
See:
w3c/resource-timing#261
and w3c/resource-timing#252
Preview | Diff
Preview | Diff