Closed
Description
Describe the bug
When callbackflow
is chained with timeout
directly, and closed with an exception, the exception won't be sent to downstream.
Coroutines version 1.8.0. Kotlin version 1.9.21.
Provide a Reproducer
val flow = callbackFlow<Int> {
close(IllegalStateException("Test Exception"))
}.timeout(5.seconds)
try {
flow.collect()
} catch (e: Exception) {
println("exception got: $e")
}
I expect this to print:
exception got: java.lang.IllegalStateException: Test Exception
But no exception is caught.
However, if I add any operator between callbackflow and timeout, it works as expected,
val flow = callbackFlow<Int> {
close(IllegalStateException("Test Exception"))
}.catch{throw it}.timeout(5.seconds)
try {
flow.collect()
} catch (e: Exception) {
println("exception got: $e")
}