-
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
Conversation
@sisidovski @domenic Will you take a look? |
Apply the suggestion. Co-authored-by: Domenic Denicola <[email protected]>
Upon the discussion, I understand that the fetch event part will always be queued. However, we need to wait for the network response so that we can reuse it as response on error. We also need to set the proper |timingInfo| for that case.
@@ -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. | |||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I am not confident but I tried to address that with #1779.
Is it what you meant?
As pointed out by the reviewer, the same algorithm can be realized without |networkFetchCompleted| and |networkFetchResult|. Let me remove them.
Since `Create Fetch Event And Dispatch` plumb |raceResponse|'s `value` when it is given, we actually do not need to wait the value. However, I found that `Create Fetch Event And Dispatch` returns [=network error=] without the |timingInfo|, it should be propagated properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand the flow of attaching timing info to network errors, since I have not seen how the callers might use it. But the overall flow looks good to me.
The fetch should plumb the output to w3c/resource-timing#415. |
This pull request originates from the work proposed by @monica-ch in #1764, but has been extensively reworked based on review feedback.
This PR corrects response handling for race-network-and-fetch-handler.
Primary Fix: The handler now correctly uses the actual fetch response for |raceResponse| instead of a generic [=network error=].
Minor Improvement: |timingInfo| is now included in the [=network error=], when returned by [=Create Fetch Event and Dispatch=], which simplifies the calling code.
Preview | Diff