Re: [whatwg/fetch] Aborting a fetch: The Next Generation (#447)

Of course, then FF prototype also does this if you abort after Response is resolved:

```
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') {
      // don't abort here this time
    }
  });
}

fetch(url, {signal, observe}).then(r => {
  console.log('fetch() resolved with a Response');
  console.log('Calling abort!');
  controller.abort();
  return 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);
  }
});
```

You get:

```
"state changed to responding"
"state changed to complete"
"fetch() resolved with a Response"
"Calling abort!"
"The request/response was aborted"
```

It seems likely something is clearly inconsistent and wrong here, but its not clear to me from the sketch what the correct defined behavior should be.  I think to progress on our prototype we need to define what happens at each state when you call abort.

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

Received on Thursday, 6 April 2017 16:36:03 UTC