-
Notifications
You must be signed in to change notification settings - Fork 1.9k
delay(0.seconds)
does not check for cancellation
#3373
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
Comments
This is the default behaviour of most of our primitives -- cancellation is "checked" only during actual suspension for the sake of performance. Could you please elaborate on whether you spotted it accidentally or if there was an actual production-driven use-case for that? |
You're right that the documentation says that it only checks for cancellation if it actually suspends. And it makes some sense that it doesn't suspend if the delay is I shot myself in the foot with this because I hadn't considered the possibility that it wouldn't check for cancellation in the
The idea was that when the state was no longer current, This has similar tones to the special cases that used to be a problem with JavaScript's |
The
delay
function claims to provide a prompt cancellation guarantee, but, if the duration passed todelay
is0
, the function simply returns without doing anything and, in particular, without checking for cancellation.Should this function be updated to check for cancellation even in the case where it does not suspend so that it guarantees that it never returns successfully if the job was cancelled before it was called?
Or, if not, should the documentation here be updated to note that
delay
does not check for cancellation if the duration is not strictly positive?The text was updated successfully, but these errors were encountered: