Closed Bug 1349950 Opened 9 years ago Closed 8 years ago

calling FetchController.abort() while Response body being consumed does not cause AbortError

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1378342

People

(Reporter: bkelly, Assigned: tt)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

Consider this test case: const url = '/'; const controller = new FetchController(); const signal = controller.signal; const observe = (observer) => { observer.addEventListener('statechange', event => { console.log('state changed to ' + observer.state); if (observer.state === 'responding') { controller.abort(); } }); } fetch(url, {signal, observe}).then(r => r.text()).then(text => console.log(text)).catch(err => { if (err.name == 'AbortError') { console.log('The request/response was aborted'); } else { console.log('Unexpected error: ' + err.name); } }); This will produce the following console output: "state changed to responding" "state changed to aborted" "state changed to complete" "" Here we aborted the fetch, but the Response.text() still produced an empty string instead of rejecting with AbortError. Similarly Response.json() will try to parse the truncated output and reject with SyntaxError.
Oh, I was getting the empty string because I was on jsbin. In devtools console on example.com that logs the entire / html file. Still, I think it should reject instead.
Attached image fetch-abort.png
I nearly filed a dupe of this.
Assignee: nobody → 446240525
Assignee: 446240525 → nobody
Tom, is this something at your wheelhouse?
Flags: needinfo?(ttung)
Start to work on this bug.
Assignee: nobody → ttung
Flags: needinfo?(ttung)
There was some question at the spec meeting if this behavior is correct or not. We should figure that out before implementing anything here.
(In reply to Ben Kelly [not reviewing due to deadline][:bkelly] from comment #5) > There was some question at the spec meeting if this behavior is correct or > not. We should figure that out before implementing anything here. Got it! Thanks for telling me that!
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: