Skip to content

Less fragile |fetchController| termination check #1780

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

Merged
merged 6 commits into from
Jun 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3263,15 +3263,17 @@ 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. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
1. Run the following substeps [=in parallel=]:
1. If |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>", then set |raceResponse| to a [=race response=] whose [=race response/value=] is null, and abort these steps.
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|:
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
1. Let |raceNetworkResult| be a [=race result=] whose [=race result/routed response=] is |raceNetworkRequestResponse| and [=race result/used route=] is {{RouterSourceEnum/"network"}}.
1. [=queue/Enqueue=] |raceNetworkResult| to |queue|.
1. [=If aborted=] and |raceFetchController| is not null, then:
1. [=fetch controller/Abort=] |raceFetchController|.
1. Set |raceResponse| to a [=race response=] whose [=race response/value=] is null.
1. Run these steps, but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>".
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
1. Let |raceNetworkResult| be a [=race result=] whose [=race result/routed response=] is |raceNetworkRequestResponse| and [=race result/used route=] is {{RouterSourceEnum/"network"}}.
1. [=queue/Enqueue=] |raceNetworkResult| to |queue|.
1. [=If aborted=] and |raceFetchController| is not null, then:
1. [=fetch controller/Abort=] |raceFetchController|.
1. Set |raceResponse| to a [=race response=] whose [=race response/value=] is null.
1. Resolve |preloadResponse| with undefined.
1. Run the following substeps [=in parallel=]:
1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
Expand Down