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

New Resource Timing issues #1201

Closed
annevk opened this issue Mar 25, 2021 · 5 comments · Fixed by #1202
Closed

New Resource Timing issues #1201

annevk opened this issue Mar 25, 2021 · 5 comments · Fixed by #1202

Comments

@annevk
Copy link
Member

annevk commented Mar 25, 2021

@noamr when looking at whatwg/xhr#319 I started looking at fetch() again and I don't understand a couple things. Let's start with this bit:

Let handleFetchDone be to finalize and report timing with response, globalObject, and "fetch".

Where does response come from here? I guess https://fetch.spec.whatwg.org/#finalize-response has to pass it on.

How does this interact with callers of HTTP-network fetch that might take this response and determine to return a network error to the caller of fetch?

Another problem here is that this might not be the final response. We end up calling these things for redirects and such too.

One way to potentially solve this is that in "fetch finale" we declare that this response is the one we need to hear about in terms of a done callback.

I suppose if "fetch finale" got a network error we could at that point invoke "done" as well, if it should happen for network errors. Do you get an entry if there's a CORS failure? I'm not sure that's currently adequately covered.

@noamr
Copy link
Contributor

noamr commented Mar 25, 2021

In "fetch finale" we attach the timing info to the response. Intermediate redirect responses don't get that, so their timing info is null, and gets discarded when the fetch params are gone, so report and finalize will be a noop.

But I do see what you're saying, that responseDone is reported for intermediate responses - it should only be reported for responses with an attached timing info (we can make that more explicit with a flag)

noamr added a commit to noamr/fetch that referenced this issue Mar 25, 2021
Only call processResponseDone for responses that have their
timing info set, which are responses that have passed CORS
and redirects.

Closes whatwg#1201
@annevk
Copy link
Member Author

annevk commented Mar 26, 2021

From IRC:

if I do fetch("https://www.google.com") and then check the last entry of window.performance.getEntriesByType("resource") it's there, so network errors do result in entries afaict

And note that in this case the network error is due to CORS. I think we should either report all network errors or none of them.

Doing this would also require some kind of integration with "fetch finale" as only there do we know if a response became a network error.

@noamr
Copy link
Contributor

noamr commented Mar 28, 2021

OK this is actually my oversight, CORS errors should be reported as an RT entry, but with some of the metrics zeroed. I'll post a PR to that effect.

@noamr
Copy link
Contributor

noamr commented Mar 28, 2021

#1202 addresses both issues now.

noamr added a commit to noamr/fetch that referenced this issue Apr 7, 2021
Only call processResponseDone for responses that have their
timing info set, which are responses that have passed CORS
and redirects.

Closes whatwg#1201
noamr added a commit to noamr/fetch that referenced this issue Apr 13, 2021
Only call processResponseDone for responses that have their
timing info set, which are responses that have passed CORS
and redirects.

Closes whatwg#1201
@annevk
Copy link
Member Author

annevk commented Apr 15, 2021

Part of this was split into #1215.

noamr added a commit to noamr/fetch that referenced this issue Apr 20, 2021
Only call processResponseDone for responses that have their
timing info set, which are responses that have passed CORS
and redirects.

Closes whatwg#1201
annevk pushed a commit that referenced this issue Apr 21, 2021
And hand processResponseDone a response.

Resource Timing PR: w3c/resource-timing#266.

Closes #1201. Follow-up: #1215.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants