You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have multiple levels of cancellable processes in the different promise chains, currently bluebird has no way of specifying what you want to cancel - either the whole thing will be canceled, or none of it.
Conceptual example:
promise x
Process A {
step 1: Wait on x
step 2:
step 3:
}
Process B {
step 1: Wait on x
step 2:
step 3:
}
In this example, if you want to cancel process A before promise x has resolved, process B will never complete, even tho it doesn't have anything to do with process A's cancellation.
A concrete example:
var p = Promise.resolve('mooose').delay(1000).cancellable()
p.then(function(x) {
console.log("Process A done")
}).catch(function(e) {
console.log("Process A was canceled (or cancelled)! Hopefully because p was cancelled directly?")
})
var processB = p.then(function(x) {
console.log("Process B started")
})
var x = processB.cancellable().then(function() {
console.log("Process B done")
}).catch(function(e) {
console.log("Process B was canceled (or cancelled)!")
})
processB.cancel()
// x.cancel() // same result
The result of this is that both process A and process B are cancelled when I only wanted to cancel process B. Is there something i'm missing about this API that resolves this?
What I would expect is that instead of cancel cancelling the farthest ancestor promise, that it would propogate to the closest descendant promise that hasn't been resolved. That way I could call processB.cancel() and only expect to see the CancellationException in one place here. Better yet would be to be able to define the boundaries of a cancelable process in some way. For example, with an api like x.cancel(processB) which would mean that the cancellation propogates up to the farthest anscestor promise of x up to processB (at which point it stops and triggers a rejection on that promise). That way cancellable processes can be nested inside other cancellable processes - exactly what you want in a complicated application.
Thoughts?
The text was updated successfully, but these errors were encountered:
If you have multiple levels of cancellable processes in the different promise chains, currently bluebird has no way of specifying what you want to cancel - either the whole thing will be canceled, or none of it.
Conceptual example:
In this example, if you want to cancel process A before promise x has resolved, process B will never complete, even tho it doesn't have anything to do with process A's cancellation.
A concrete example:
The result of this is that both process A and process B are cancelled when I only wanted to cancel process B. Is there something i'm missing about this API that resolves this?
What I would expect is that instead of
cancel
cancelling the farthest ancestor promise, that it would propogate to the closest descendant promise that hasn't been resolved. That way I could callprocessB.cancel()
and only expect to see the CancellationException in one place here. Better yet would be to be able to define the boundaries of a cancelable process in some way. For example, with an api likex.cancel(processB)
which would mean that the cancellation propogates up to the farthest anscestor promise of x up to processB (at which point it stops and triggers a rejection on that promise). That way cancellable processes can be nested inside other cancellable processes - exactly what you want in a complicated application.Thoughts?
The text was updated successfully, but these errors were encountered: