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)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
DUPLICATE
of bug 1378342
People
(Reporter: bkelly, Assigned: tt)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file)
|
235.53 KB,
image/png
|
Details |
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.
| Reporter | ||
Comment 1•9 years ago
|
||
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.
| Assignee | ||
Comment 4•9 years ago
|
||
Start to work on this bug.
Assignee: nobody → ttung
Flags: needinfo?(ttung)
| Reporter | ||
Comment 5•9 years ago
|
||
There was some question at the spec meeting if this behavior is correct or not. We should figure that out before implementing anything here.
| Assignee | ||
Comment 6•9 years ago
|
||
(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!
Updated•8 years ago
|
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•