Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out no-cors requests from the race-network-request #1757

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sisidovski
Copy link
Contributor

@sisidovski sisidovski commented Mar 3, 2025

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

@yoshisatoyanagisawa
Copy link
Collaborator

You intend to make all "no-cors" (i.e. cross origin resource fetches) requests to fallback to fetch handler even if the race-network-and-fetch-handler source is set, right?

@yoshisatoyanagisawa yoshisatoyanagisawa self-requested a review March 4, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants