-
Notifications
You must be signed in to change notification settings - Fork 319
Fix: race-network-and-fetch-handler now uses actual |raceResponse| #1777
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
Changes from 8 commits
f2d5c72
c39d796
f206baf
7102987
c9a9907
9a14512
8eec31a
c02659f
e2a3f08
5006fff
51832d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
yoshisatoyanagisawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing setup seems a bit fragile to me. The definition of abort when only operates between steps, and there are only two steps nested under "If aborted"... In fact there is only one step before this PR. Probably there should be a check on fetchController's state inside the processResponse callback? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not confident but I tried to address that with #1779. |
||
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|: | ||
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then: | ||
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|. | ||
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. Otherwise, set |raceResponse|'s [=race response/value=] to a [=network error=]. | ||
1. Set |networkFetchResult| to |raceNetworkRequestResponse|. | ||
1. Set |networkFetchCompleted| to true. | ||
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. Set |networkFetchCompleted| to true. | ||
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|. | ||
|
@@ -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: | ||
yoshisatoyanagisawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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. | ||
yoshisatoyanagisawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. If |networkFetchResult| is null: | ||
1. Return |timingInfo|. | ||
1. Set |networkFetchResult|'s [=service worker timing info=] to |timingInfo|. | ||
1. Return |networkFetchResult|. | ||
1. If |result|'s [=race result/used route=] is {{RouterSourceEnum/"network"}}, then: | ||
1. Set |routedResponse|'s [=service worker timing info=] be set to |timingInfo|. | ||
1. Set |routedResponse|'s [=service worker timing info=]'s [=service worker timing info/worker final router source=] be set to |result|'s [=race result/used route=]. | ||
|
Uh oh!
There was an error while loading. Please reload this page.