-
-
Notifications
You must be signed in to change notification settings - Fork 17
Support promise cancellation #13
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be removed, relying on the default cancelling behaviour of the input promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default cancelling behaviour of the input promise
I'm not sure I follow, but how can we rely on its handling?
It's my understanding that the input promise can support cancellation, but we can't really rely on its outcome.
Also, I'm not sure about the rejection value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case, it is safe to use the default cancellation flow because the promise is cancelled before the timer rejects the promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide a gist / PR that exhibits this? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to gist this. We should simply do not take responsibility for the cancelling behaviour (which is not necessarily rejection) from the root promise. Why reject here if the root promise decides to do something else? We should only recject if an actual timeout occurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting idea – albeit different to what we've discussed in #3 so far :)
I'll take a look at this and see how this works out.
This has some different implications than the current implementation. In particular, we can no longer rely on the outcome of the cancel() call (though this may not necessarily be a bad thing as you've pointed out).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is different. Sorry for raising this here instead of the original issue. The idea for the current cancellation implementation has been to not give consumers the ability to reject a promise through the cancel() call but leave all responsibilities to the promise producer.
I'd vote for leaving all responsibilities to the root promise and only take them over (reject) once the timeout occurs. This means, as long as no timout occurs, everything works as we never called timeout() at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea for the current cancellation implementation has been to not give consumers the ability to reject a promise through the cancel() call but leave all responsibilities to the promise producer.
I think this makes perfect sense, thanks for the discussion! 👍
I've just filed #18 as a better alternative to this PR.
resolve()andreject()RuntimeExceptiontimeout()RuntimeExceptiontimeout()is not affectedCloses #3