Re: [fetch] Aborting a fetch (#27)

It seems like you have covered all the important requirements. I like that you have introduced a `finally` rather than a `onCancelled` callback, as this simplifies things. I assume the `finally` callback doesn't take any arguments?
```js
then().finally(function(){
  assert(arguments.length === 0);
});
```

> And there's the problem. Although .cancel was called on this [waitingPromise] unsettled promise, it continues to resolve with fetchPromise.

This can be solved by having the promise that .cancel is called on ignore any result given to it. So `waitingPromise` in your example would mark itself as `CANCELLED` so that even if the promise it is waiting for is resolved, itself wont resolve. In addition it calls `cancel()` on any promise that is is waiting for (if the promise it is waiting for has `cancel` defined).

The advantage with this is that it can work even without `CancellablePromise`s:

```js
const a = fetch(url);
const b = a.then(r => r.json());
const c = b.then(json => somethingThatReturnsAnOrdinaryPromise(json));
c.cancel();
```
If both `a` and `b` are resolved `CancellablePromise`s, then cancelling `c` will try to cancel the result of `somethingThatReturnsAnOrdinaryPromise`, which can't be cancelled. But it will still ignore the result, so from the outside it will look the same. This makes it possible to combine `CancellablePromise`s with existing Promise implementations without worry.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-93059812

Received on Tuesday, 14 April 2015 21:03:39 UTC