CLOVIS
04/09/2023, 10:25 AMraise
DSL scope and should be used carefully. More information can be found in the typed errors documentation." The typed errors documentation never mentions flows, however… What does it mean?
I'm stuck on a delay
in a channelFlow
that never completes, maybe this is the origin of the problem?mitch
04/09/2023, 11:52 AMval eitherFlow: Either<String, Flow<Int>> = either {
flow {
emit(1)
emit(2)
raise("failed") // leak
emit(3)
}
}
which in terms cancellation, that will only manifest when the flow is executed, so that raise will leak.. as can be seen when trying to materialize the flow.
suspend fun main() {
eitherFlow.map { flow -> flow.toList() }
}
// Exception in thread "main" arrow.core.raise.RaiseLeakedException: raise or bind was called outside of its DSL scope, and the DSL Scoped operator was leaked
// This is kind of usage is incorrect, make sure all calls to raise or bind occur within the lifecycle of effect { }, either { } or similar builders.
mitch
04/09/2023, 11:55 AMCLOVIS
04/09/2023, 12:37 PMCLOVIS
04/09/2023, 12:40 PMcontext(Raise<*>) fun flow(context(NoRaise) block: FlowEmitter<T>.() -> Unit)
Not perfect because you have to override the flow builder, and it's quite a lot of stuff to add, but it worksYoussef Shoaib [MOD]
04/09/2023, 8:07 PM