promises-aplus / cancellation-spec

Discussion and drafts of a possible promise cancellation spec.
24 stars 5 forks source link

Cancel every promise in the chain, or only the deepest cancellable ancestor? #10

Open bergus opened 10 years ago

bergus commented 10 years ago

When I cancel a chain of promises, how do error handlers work?

We'll assume automatic propagation of the cancellation to parent promises, regardless how it's implemented. Let's have a

var cancellable = parentCancellable.then(doSomething, handleSomething);

Now when I call cancellable.cancel() (or whatever we use to signal cancellation), then parentCancellable will be rejected with a CancellationError. But what happens to cancellable? Is it supposed to be rejected with the same error? Or does its fate depend on the result of handleSomething() (which is required to be called by the A+spec)? Both options have their problems:

reject it:

Sure, no handler that cannot deal with a CancellationError should be executed at all, but my hunch says the only the fewest catch clauses involve typechecking.

let errors bubble as usual: