Skip to content

Conversation

@quasi-mod
Copy link

@quasi-mod quasi-mod commented May 30, 2025

This will update the HttpFetch algorithm, particularly the handling of the response for Service Worker fetch (handle fetch step). Currently, the response of handle fetch step is assumed to return the response type (or null, if the ServiceWorker couldn't handle the fetch and need to fallback to the network request). However, we have changed the handle fetch step to also return service worker timing info when the ServiceWorker static routing API used, so that the corresponding timing information are correctly exposed when the ServiceWorker could not handle the fetch. To support this new return type, we need to update the handling of the response of handle fetch.

To expose the Service Worker Timing Info to the resource timing API, we also associate them to the Fetch Timing Info so that it could be later referenced.

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


Preview | Diff

@quasi-mod
Copy link
Author

This PR is for the resource timing API changes of ServiceWorker static routing API. Since some of the criterias are not met yet, let me make this as draft.

@quasi-mod
Copy link
Author

Let me make this a PR and ask for opinions about this.

@quasi-mod
Copy link
Author

@yoshisatoyanagisawa Could you check if this make sense? Thanks!

fetch.bs Outdated
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
<a for="fetch timing info">final service worker start time</a> to
<var>serviceWorkerStartTime</var>.
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s

Choose a reason for hiding this comment

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

It is not a blocker but resource-timing may not not have a trivial way to know response, right? I just wondered why we need to copy the timing info.

Copy link
Author

Choose a reason for hiding this comment

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

I have to double check, but I think you are right. We already set the timing info directly to fetch timing info, so maybe we do not need to set them to the response.

Copy link
Author

Choose a reason for hiding this comment

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

Let me double check and update the draft

Copy link
Author

Choose a reason for hiding this comment

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

Just to clarify, I think this is copying the response's timing_info's service worker timing info into the fetchParams timing info's service worker timing info, which does not expose response, so I feel like this is right.

Copy link

@yoshisatoyanagisawa yoshisatoyanagisawa Nov 21, 2025

Choose a reason for hiding this comment

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

Will it be used for the redirect?
I revisited this and see how fetchParams are used, and it looks used "If internalResponse’s status is a redirect status:".

If so, lgtm.

@quasi-mod
Copy link
Author

@annevk Thanks for taking a look offline!
I have rebased on top of recent change.

Could you publish the comments you made during our offline chat at TPAC last week? Thanks!

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.

Oh, I thought I had. Fortunately GitHub did preserve them. Sorry about that!

quasi-mod and others added 2 commits November 21, 2025 08:57
This will update the HttpFetch algorithm, particularly the handling of
the response for Service Worker fetch (`handle fetch` step). Currently,
the response of handle fetch step is assumed to return the `response`
type (or null, if the ServiceWorker couldn't handle the fetch and need
to fallback to the network request). However, we have changed the
`handle fetch` step to also return `service worker timing info` when the
ServiceWorker static routing API used, so that the corresponding timing
information are correctly exposed when the ServiceWorker could not handle
the fetch. To support this new return type, we need to update the handling
of the response of `handle fetch`.

To expose the Service Worker Timing Info to the resource timing API, we
also associate them to the Fetch Timing Info so that it could be later
referenced.
@annevk annevk force-pushed the resource-timing/01/expose-service-worker-timing branch from 4b9cee0 to 025ab33 Compare November 21, 2025 08:00
@annevk
Copy link
Member

annevk commented Nov 21, 2025

@quasi-mod I decided to take a pass at the formatting myself since it's your first contribution. While doing that I ended up fixing a couple of minor errors and also realized that the non-null check is redundant with the type checks. The result is a much cleaner diff. Could you please verify that all my changes were indeed editorial? (Note that I forced pushed to your branch to also rebase it so if you want to make further changes please be aware of that.)

I'd also like to hear back from @yoshisatoyanagisawa about the unresolved thread above.

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.

3 participants