Given:
var outerFetchPromise = fetch(url);
var resultPromise = outerFetchPromise.then(response => {
var jsonPromise = response.json();
var innerFetchPromise = jsonPromise.then(data => fetch(data.url));
var textPromise = innerFetchPromise.then(r => r.text());
return textPromise;
});
If resultPromise.cancel() is called before the handler has executed, the handler will never execute
If resultPromise.cancel() is called after the handler has executed but before textPromise settles, it has the same effect as calling textPromise.cancel() + resultPromise will be cancelled. This seems to match what is written in the gist.
If resultPromise.cancel() is called after textPromise has settled, it will have no effect
First I need to explain something. Resolving promise with a promise in bluebird doesn't retain reference from the target to the follower because it leads to memory leaks in many reasonable and intuitive patterns. Resolving promise with a promise is usually implemented like:
target.then(followerResolve, followerReject)
(or some equivalent optimization, but the main point is all of them make target have a reference to follower). In bluebird follower instead becomes a proxy for the target (follower holds reference to target rather than other way around). This eliminates the memory leak but it makes it impossible to do branch counting for promises resolved with promises. So in bluebird the refcount would be 1 instead of 2 and you would need to use the `.then()` workaround to avoid cancelling for the other consumer.