-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
In the current version of the library, withTimeout
throws TimeoutCancellationException
when a timeout was exceeded.
It can lead to very subtle errors, for example:
launch {
val result = withTimeout(...) {
// ... some computation ...
}
// process result
}
TimeoutCancellationException
is CancellationException
, thus is never reported.
But in the snippet above, it's likely to be a programmatic error. If it is expected to miss the deadline, then withTimeoutOrNull
should be used explicitly.
My proposal is deprecation of TimeoutCancellationException
and replacement with TimeoutException
that is not CancellationException
hrach, zach-klippenstein, maxmodestov, artbez, Dougrinch and 31 more