Filter out no-cors requests from the race-network-request #1757
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will address the comment in whatwg/fetch#1737 (comment).
When "race-network-request" is matched as the router rule, the service worker starts a network request in parallel with dispatching the fetch event. The response is keyed by request and managed in race response map. And the fetch API will check this map whether the request is already started by the service worker, and use its response if the corresponding entry is found.
We use ok-status to tell if the response is successful or not, and use the response only when the status is ok-status. This is needed to support the offline capability. However, with the request mode "no-cors", the response will be filtered. The filtered response's status is always 0, so this is handled as a failure in "race-network-request" even without this change. But it would be better that we explicitly filter out "no-cors" in the handle fetch algorithm.
Once we get an agreement to this change, I'll add a WPT and fix Chrome behavior.
Preview | Diff