[whatwg/fetch] HTTP-redirect does not call processResponse and breaks navigation expectations (Issue #1629)

["create navigation params by fetching"](https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching) in HTML navigation spec does following:
> "6. Otherwise, process the next manual redirect for fetchController."

and has a note:
> "This will result in calling the processResponse we supplied above, during our first iteration through the loop, and thus setting response."

but if we will look into fetch spec that what will happen while processing next manual redirect:

1. Process manual redirect is set to [HTTP-redirect fetch](https://fetch.spec.whatwg.org/#concept-http-redirect-fetch) (https://fetch.spec.whatwg.org/#concept-http-fetch 7.2, "manual" case).
2. Step 20 of [HTTP-redirect fetch](https://fetch.spec.whatwg.org/#concept-http-redirect-fetch) calls [main fetch](https://fetch.spec.whatwg.org/#concept-main-fetch) with fetchParams and true (redirect param).
3. [main fetch](https://fetch.spec.whatwg.org/#concept-main-fetch) does early return of response on step 13:
> If recursive is true, then return response.

because "HTTP-redirect fetch" passed recursive=true earlier.

This way [main fetch](https://fetch.spec.whatwg.org/#concept-main-fetch) never reaches [fetch response handover](https://fetch.spec.whatwg.org/#fetch-finale) where processResponse is called which means navigation code will stuck waiting for processResponse to be called.

I checked spec commit history and in the past instead of
> Return the result of running main fetch given fetchParams and true.

there was in the [HTTP-redirect fetch](https://fetch.spec.whatwg.org/#concept-http-redirect-fetch)
> Return the result of performing a main fetch using request with recursive flag set if request's redirect mode is not manual.

note that recursive should be false for manual navigation was introduced here https://github.com/whatwg/fetch/pull/499/commits/c958914d772b6b1089b3f361958cbad66b546b9c

and then got removed https://github.com/whatwg/fetch/commit/12dd6fa8ca76bd3bdff0c65a0c5a84b3ca870c3d

but for me it looks like this note should not have been removed because with redirect=false in manual redirect mode processResponse will be called which is what navigation expects.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1629
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1629@github.com>

Received on Sunday, 9 April 2023 18:21:13 UTC