- From: Marius Gundersen <notifications@github.com>
- Date: Tue, 31 Mar 2015 08:10:54 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/27/88126830@github.com>
> should silently keep going because there was nothing to cancel ... right ? Yes, since all the promises in the array are `fulfilled` the promise returned by `Promise.all()` will also be fulfilled, so it is too late to cancel it. Maybe the `cancel()` could return a `pending` promise: ```js var p = Promise.all([Promise.resolve()]); //p.@state = "fulfilled" var q = p.cancel(); //p.@state = "fulfilled" //q.@state = "pending" ``` > if a cancelable Promise returns inside a then another cancelable Promise, should the last cancel eventually cancel this one, instead of the original one that generated the chain? The promise returned by `then(func)` is not the promise returned by the function `func`: ```js var innerP; var outerP = Promise.resolve().then(r => (innerP = new Promise(r => r())); outerP === innerP //false ``` When calling `c = a.then(() => b)`, then `c` is a promise that is only ever waiting for one other promise to resolve, either the previous one in the chain (`a`) or the promise returned by the function passed to it (`b`). This means that calling `cancel` on `c` will only cancel the one it is waiting for. If `a` hasn't resolved yet, then `a` will be cancelled and nothing will happen to `b`, since it hasn't been started yet. If `a` has resolved, then `a` will not be cancelled (since it is resolved), and `b` will be cancelled. If `b` has resolved, then `c` has resolved, and cancelling `c` will be a no-op. It will be too late. --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/27#issuecomment-88126830
Received on Tuesday, 31 March 2015 15:11:24 UTC