You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a basic test with timeout in an Android app. In this case, println never is called because TimeoutCancellationException is not thrown, in normal behavior the app should to crash, but it is not.
fun testeTimeout() {
mainScope.launch {
val ret = getTimeoutInt()
println(ret)
}
}
suspend fun getTimeoutInt() : Int {
return withTimeout(1000) {
delay(5000)
10
}
}
However, if the getTimeoutInt is enclosed with try/catch the exception is thrown normally.
fun testeTimeout() {
mainScope.launch {
try {
val ret = getTimeoutInt()
println(ret)
} catch (e: Exception) {
println("ret = $e)
}
}
}
ret = kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 1000 ms
Is it a bug that?
Kotlin : 1.4.20-RC
Coroutine: kotlinx-coroutines-android:1.4.1
Thank you
The text was updated successfully, but these errors were encountered:
TimeoutCancellationException is successfully thrown from delay method (you can see it by wrapping it into try-finally or try-catch) and coroutine from testeTimeout is terminated. It's just not printed to the console
I see, this is because TimeoutCancellationException is CancellationException and CancellationException can neither crash an application nor get reported.
Let me close it as a duplicate of #1374
Hello guys,
Here is a basic test with timeout in an Android app. In this case, println never is called because TimeoutCancellationException is not thrown, in normal behavior the app should to crash, but it is not.
However, if the getTimeoutInt is enclosed with try/catch the exception is thrown normally.
ret = kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 1000 ms
Is it a bug that?
Kotlin : 1.4.20-RC
Coroutine: kotlinx-coroutines-android:1.4.1
Thank you
The text was updated successfully, but these errors were encountered: