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

One issue with canceling an entire chain is that it could leak memory. Currently a pending promise can be garbage collected if nothing in referencing it. In the chain `c = a.then(() => b)`, `a` can be garbage collected because neither `b` nor `c` hold a reference to it (`a` holds a reference to `c`). 

With cancellation there needs to be a reference in both directions, so `c` needs to have a reference to `a` so it can cancel `a`. 

This isn't a very big issue though, since `c` can drop it's reference to `a` the moment it is cancelled or resolved (by `a`), thereby breaking the reference chain. This means that there will only be a memory leak for forever pending promises:

```js
var neverResolving = new Promise(r => 'I never resolve');
var leaker = neverResolving.then(a => 'I hold on to neverResolving');
neverResolving = null;
//if leaker is a normal promise, neverResolving will now be garbage collected.
//if leaker is a cancellable promise, neverResolving will not be garbage collected until leaker is!
```

Since this is only an issue with promises that never resolve, I don't think it is much to worry about.

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

Received on Wednesday, 1 April 2015 13:57:08 UTC