New issue
Advanced search Search tips

Issue 817687 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Compat

Blocking:
issue 750599



Sign in to add a comment

Fetch Response body methods reject with the wrong exception on abort

Project Member Reported by ricea@chromium.org, Mar 1 2018

Issue description

The following code:

const controller = new AbortController();
const signal = controller.signal;
const response = await fetch('big.bin', { signal });
response.arrayBuffer().catch(e => console.log(e));
controller.abort();

Should log an AbortError DOMException. As currently implemented, it logs a TypeError instead.

This is tested in the wpt test external/wpt/fetch/api/abort/general.html which reports the following failures:

FAIL Fetch aborted & connection closed when aborted after calling response.arrayBuffer() assert_throws: function "function() { throw e }" threw object "TypeError: Failed to fetch" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
FAIL Fetch aborted & connection closed when aborted after calling response.blob() assert_throws: function "function() { throw e }" threw object "TypeError: Failed to fetch" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
FAIL Fetch aborted & connection closed when aborted after calling response.formData() assert_throws: function "function() { throw e }" threw object "TypeError: Failed to fetch" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
FAIL Fetch aborted & connection closed when aborted after calling response.json() assert_throws: function "function() { throw e }" threw object "TypeError: Failed to fetch" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
FAIL Fetch aborted & connection closed when aborted after calling response.text() assert_throws: function "function() { throw e }" threw object "TypeError: Failed to fetch" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20

This is due to be fixed in the implementation of step 3 in https://docs.google.com/document/d/1OuoCG2uiijbAwbCw9jaS7tHEO0LBO_4gMNio1ox0qlY/edit#heading=h.fvc7d7q07oio ("Fetch API cancellation design doc" section "Body cancellation").
 

Comment 1 by ricea@chromium.org, Mar 1 2018

Blocking: 750599
See also: issue 577097

Comment 3 by ricea@chromium.org, Mar 1 2018

#2 Interesting. I think I will proceed with the narrowly-scoped abort-only fix, but once issue 577097 is fixed we may not need it.
Project Member

Comment 4 by bugdroid1@chromium.org, Mar 20 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/024df98cb4319d467ac54ae5ca40f13413e0f2bf

commit 024df98cb4319d467ac54ae5ca40f13413e0f2bf
Author: Adam Rice <ricea@chromium.org>
Date: Tue Mar 20 12:24:55 2018

Correctly reject in-progress body methods with AbortError

Prior to this change, response body methods such as
response.body.arrayBuffer() would reject with a TypeError if the fetch
was aborted. This change makes them correctly reject with an AbortError
instead.

This implements stage #3 of the "Body Cancellation" section of the
design doc:

https://docs.google.com/document/d/1OuoCG2uiijbAwbCw9jaS7tHEO0LBO_4gMNio1ox0qlY/edit#heading=h.fvc7d7q07oio

Bug:  817687 
Change-Id: Ifde322d9c22485a8ba9d14fd4ffca65c4fb4745a
Reviewed-on: https://chromium-review.googlesource.com/954765
Commit-Queue: Adam Rice <ricea@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544335}
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/fetch/api/abort/general-serviceworker.https-expected.txt
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/fetch/api/abort/general-sharedworker-expected.txt
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/fetch/api/abort/general.any-expected.txt
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/fetch/api/abort/general.any.worker-expected.txt
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/lint.whitelist
[add] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-abort.js
[add] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/serviceworker/cache-abort.https.html
[add] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/window/cache-abort.https.html
[add] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/worker/cache-abort.https.html
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.cpp
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/core/fetch/Body.cpp
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/core/fetch/BodyStreamBuffer.cpp
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/core/fetch/BodyStreamBufferTest.cpp
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/core/fetch/BytesConsumerTestUtil.h
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/core/fetch/FetchDataLoader.h
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/modules/cachestorage/Cache.cpp
[modify] https://crrev.com/024df98cb4319d467ac54ae5ca40f13413e0f2bf/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp

Comment 5 by ricea@chromium.org, Mar 20 2018

Status: Fixed (was: Assigned)

Sign in to add a comment