Re: [w3c/ServiceWorker] Add race-network-and-cache source to static routing api. (PR #1764)

@sisidovski commented on this pull request.



> @@ -1591,14 +1591,16 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
 
       dictionary RouterSourceDict {
         DOMString cacheName;
+        DOMString raceNetworkAndCacheCacheName;

I'm not sure if we need a dedicated field to specify a cache name for race-network-and-cache. Also, could you give some example of how the final API shape will look like?

> @@ -3256,7 +3261,45 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
                   1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
                   1. If |fetchHandlerResponse| is not null and not a [=network error=], and |raceFetchController| is not null, [=fetch controller/abort=] |raceFetchController|.
                   1. [=queue/Enqueue=] |fetchHandlerResponse| to |queue|.
-              1. Wait until |queue| is not empty.
+                  1. Set |fetchHandlerCompleted| to true.
+              1. Wait until |queue| is not empty or (|networkFetchCompleted| is true and |fetchHandlerCompleted| is true).

I'm not sure if we really really need to introduce `networkFetchCompleted` and `fetchHandlerCompleted`. For `race-network-and-fetch-handler`, the race is expressed by `queue`. Why we need these two flags?

It looks `networkFetchCompleted` doesn't wait for the promise resolve. So assuming `queue` can be still empty even when `networkFetchCompleted` is true. This will return null, which means the fetch event fallback in the handle fetch algorithm.

Also not sure why we should wait for `fetchHandlerCompleted` as well. This means we have to wait for both the network and fetch handler completion.

IIUC `race-network-and-fetch-handler` won't run the race anymore after this change.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1764#pullrequestreview-2777173967
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/pull/1764/review/2777173967@github.com>

Received on Friday, 18 April 2025 00:58:42 UTC