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

Add server-timing to timing info struct #1406

Merged
merged 5 commits into from
Apr 21, 2022
Merged

Conversation

noamr
Copy link
Contributor

@noamr noamr commented Feb 27, 2022

Will be used by w3c/server-timing#87

Decode and split Server-Timing headers, and append the raw headers to the fetch timing info. The server timing spec would later parse these headers and expose them.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Why can't the calling specification look at the response itself?

Also, I thought these headers might appear as trailer headers?

@noamr
Copy link
Contributor Author

noamr commented Feb 28, 2022

Why can't the calling specification look at the response itself?

We didn't want to pass the whole response to resource timing. We're passing only the timing info.

Also, I thought these headers might appear as trailer headers?

They can, but I wanted to do this in iterations. Also they're not a widely adopted feature and I wanted to spec the consensus common denominator first.

@annevk
Copy link
Member

annevk commented Feb 28, 2022

So dealing with them in trailer headers doesn't have implementer agreement? It seems a little weird for Fetch to process this header as it doesn't seem to be related to information hiding, but if this is the only thing Resource Timing needs I guess it makes sense. Perhaps we should add some comments though that in case this changes we need to change the setup.

@noamr
Copy link
Contributor Author

noamr commented Feb 28, 2022

So dealing with them in trailer headers doesn't have implementer agreement? It seems a little weird for Fetch to process this header as it doesn't seem to be related to information hiding, but if this is the only thing Resource Timing needs I guess it makes sense. Perhaps we should add some comments though that in case this changes we need to change the setup.

Added a comment, is that sufficient? Not sure if any more clarification is needed at this point.

@annevk
Copy link
Member

annevk commented Mar 1, 2022

"So dealing with them in trailer headers doesn't have implementer agreement?" is something I'd still like an answer to. The note also doesn't tackle this adequately I think as trailers can be received at a much later point so you probably want a separate data structure for them.

I also didn't really mean to ask for note, but rather a comment that indicates we might want to change approach if we end up having to inspect and parse other headers for Resource Timing. At that point it might become better to just pass Resource Timing the header list.

@noamr
Copy link
Contributor Author

noamr commented Mar 1, 2022

"So dealing with them in trailer headers doesn't have implementer agreement?" is something I'd still like an answer to. The note also doesn't tackle this adequately I think as trailers can be received at a much later point so you probably want a separate data structure for them.

I don't think that would be necessary. Resource timing is only reported after response end, at which point those would be available. But in any case, I would defer this to when there's consensus about trailers.

I also didn't really mean to ask for note, but rather a comment that indicates we might want to change approach if we end up having to inspect and parse other headers for Resource Timing. At that point it might become better to just pass Resource Timing the header list.

Got it.

@noamr
Copy link
Contributor Author

noamr commented Mar 1, 2022

See #980, #981 and w3c/server-timing#68 for conversation about trailer suopport.

@noamr
Copy link
Contributor Author

noamr commented Mar 8, 2022

@annevk anything missing in this?

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

I'd like @ddragana or @valenting to comment as well given that Firefox does support trailers here if I'm not mistaken, but this looks okay to me. I pushed some minor commits that I hope are acceptable.

I'm not entirely sure about the approach to processing this header being shared across two specifications, but I also cannot really think of a better way of doing it.

@noamr
Copy link
Contributor Author

noamr commented Mar 10, 2022

I'd like @ddragana or @valenting to comment as well given that Firefox does support trailers here if I'm not mistaken, but this looks okay to me. I pushed some minor commits that I hope are acceptable.

Thanks, of course they are.

I'm not entirely sure about the approach to processing this header being shared across two specifications, but I also cannot really think of a better way of doing it.

I agree it's not ideal but it's also how it looks like in implementations, I believe it's the the lesser of evils.

@annevk
Copy link
Member

annevk commented Mar 11, 2022

The other thing I realized looking at Firefox's implementation a bit more is that it limits this feature to secure contexts. That's probably something we want to account for here and not on the API side.

@noamr
Copy link
Contributor Author

noamr commented Mar 14, 2022

The other thing I realized looking at Firefox's implementation a bit more is that it limits this feature to secure contexts. That's probably something we want to account for here and not on the API side.

Done, and added a WPT. Chromium implementation, however, currently allows Server-Timing in http. (Safari doesn't support Server-Timing at all).
@yoavweiss WDYT about limiting ST to HTTPS?

@yoavweiss
Copy link
Collaborator

I believe that would be a breaking change from Chromium's perspective. Is there any particular reason why Server-Timing should be limited to secure contexts? Any security/privacy issues that arise from the fact that it is not?
Also, what are the benefits of enforcing this limitation on the Fetch side?

@valenting
Copy link

Looking back at the intent to ship I think the main motivation for limiting this to secure origins was Mozilla's policy of doing so.

I also seem to recall a discussion where trailers were causing problems with middleboxes over HTTP, but I can't find any references to that at this time.

@noamr
Copy link
Contributor Author

noamr commented Mar 15, 2022

Looking back at the intent to ship I think the main motivation for limiting this to secure origins was Mozilla's policy of doing so.

I also seem to recall a discussion where trailers were causing problems with middleboxes over HTTP, but I can't find any references to that at this time.

Seems like the conversation didn't result in a consensus, which is unfortunate since currently server-timing is not interoperable in that way.

@annevk
Copy link
Member

annevk commented Mar 15, 2022

Also, what are the benefits of enforcing this limitation on the Fetch side?

Mainly principle of least privilege.

@yoavweiss
Copy link
Collaborator

Also, what are the benefits of enforcing this limitation on the Fetch side?

Mainly principle of least privilege.

OK. At the same time, that doesn't seem in line with what some implementations are doing.

@noamr
Copy link
Contributor Author

noamr commented Mar 17, 2022

I amended the PR to reflect the Gecko/Chromium status quo: the headers are always sent for https, and make http something that's up to the user-agent's discretion. It's not perfect in terms of interoperability but at least it makes the part that are in consensus specified.

fetch.bs Outdated Show resolved Hide resolved
@noamr
Copy link
Contributor Author

noamr commented Apr 11, 2022

@annevk anything missing?

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

@yoavweiss want to have another look?

Copy link
Collaborator

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

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

LGTM

@annevk annevk merged commit 14898c0 into whatwg:main Apr 21, 2022
@noamr noamr deleted the server-timing branch April 21, 2022 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants