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

@monica-ch commented on this pull request.



> +              1. Run the following substeps [=in parallel=]:
+                  1. [=map/For each=] |cacheName| → |cache| of the |registration|'s [=service worker registration/storage key=]'s [=name to cache map=]:
+                      1. If |source|["{{RouterSourceDict/raceNetworkAndCacheCacheName}}"] [=map/exists=] and |source|["{{RouterSourceDict/raceNetworkAndCacheCacheName}}"] [=string/is=] not |cacheName|, [=continue=].
+                      1. Let |requestResponses| be the result of running [=Query Cache=] with |request|, a new {{CacheQueryOptions}}, and |cache|.
+                      1. Let |globalObject| be null.
+                      1. If |requestResponses| is not an empty [=list=], then:
+                          1. Let |requestResponse| be the first element of |requestResponses|.
+                          1. Let |response| be |requestResponse|'s response.
+                          1. If |response|'s [=response/type=] is "`opaque`", and |globalObject| is null:
+                              1. Set |globalObject| to the result of running [=Setup ServiceWorkerGlobalScope=] with |activeWorker|.
+                          1. If |globalObject| is null, [=continue=].
+                          1. If |response|'s [=response/type=] is "`opaque`", and [=cross-origin resource policy check=] with |globalObject|'s [=environment settings object/origin=], |globalObject|, "", and |response|'s [=filtered response/internal response=] returns <b>blocked</b>, then [=continue=].
+                          1. [=queue/Enqueue=] |response| to |queue|.
+                          1. If |raceFetchController| is not null, [=fetch controller/abort=] |raceFetchController|.
+              1. Wait until |queue| is not empty.
+              1. If |queue| is empty, return null.

Added flags to track if they are finished and Wait until |queue| is not empty step is updated so it won't wait indefinitely if both fails. The next step handles if they fail and |queue| is empty our algorithm returns.

Is this change, okay? Feel free to suggest for corrections or if it is unclear

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

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

Received on Thursday, 17 April 2025 00:33:13 UTC