Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onCancel() handler prevents automatic cancellation propagation #57

Closed
lilyball opened this issue Jul 26, 2020 · 1 comment
Closed

onCancel() handler prevents automatic cancellation propagation #57

lilyball opened this issue Jul 26, 2020 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@lilyball
Copy link
Owner

The existence of an onCancel handler prevents automatic cancellation propagation from other children from cancelling the upstream parent. An onCancel handler should always act like a tap, as it's rather surprising that registering to be notified when a promise is cancelled would prevent the promise from being cancelled.

@lilyball lilyball added the bug Something isn't working label Jul 26, 2020
@lilyball lilyball added this to the Next milestone Jul 26, 2020
@lilyball
Copy link
Owner Author

This one is complicated because making it behave like tap means ignoring cancellation requests, except we need requestCancel() to continue working as promise.then(…).catch(…).onCancel(…) should have the same behavior as promise.always(…).

Currently, any promise that propagates cancellation also prevents its parent from being automatically cancelled if the child hasn't been cancelled. What we want for onCancel is a way to tell the parent that it should cancel if it goes out of scope and it has no children that propagate cancellation.

We could possibly do this by having the cancellation request increment the upstream promise's observer count prior to propagating the cancel. This way the upstream promise is then marked as having had observers if it hadn't already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant