Re: [w3c/ServiceWorker] Reuse network response on both network and fetch handler failed (PR #1777)

@sisidovski commented on this pull request.



> @@ -3282,6 +3287,15 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
                   1. Wait until |queue| is not empty.
                   1. Let |result| be the result of [=dequeue=] |queue|.
                   1. Let |routedResponse| be |result|'s [=race result/routed response=].
+                  1. If |routedResponse| is null or a [=network error=], then:

When can `routedResponse` be a network error?

> @@ -3282,6 +3287,15 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
                   1. Wait until |queue| is not empty.
                   1. Let |result| be the result of [=dequeue=] |queue|.
                   1. Let |routedResponse| be |result|'s [=race result/routed response=].
+                  1. If |routedResponse| is null or a [=network error=], then:
+
+                      Note: the [=Create Fetch Event and Dispatch=] return value is queued regardless of its value. Failure response means the raced fetch handler failed.
+
+                      1. Wait until |networkFetchCompleted| is true.

I assume this can be changed to `Wait until raceResponse’s value is not "pending".`, just like we already did in the step 19.3.1 in the Create Fetch Event and Dispatch algorithm.

Then probably we don't need `networkFetchCompleted` and `networkFetchResult` anymore.


> @@ -3263,16 +3263,21 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
                   1. Let |queue| be an empty [=queue=] of [=race result=].
                   1. Let |raceFetchController| be null.
                   1. Let |raceResponse| be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
+                  1. Let |networkFetchCompleted| be false.
+                  1. Let |networkFetchResult| be null.

I think the option 2 is simpler. By using `raceResponse`, probably we don't have to introduce `networkFetchCompleted` as well.

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

Message ID: <w3c/ServiceWorker/pull/1777/review/2919623336@github.com>

Received on Thursday, 12 June 2025 05:59:20 UTC