Hi all, I was surprised to see, that canceling a j...
# coroutines
u
Hi all, I was surprised to see, that canceling a job that is suspended in a
consumeEach
will execute code after the
consumeEach
. Is this expected behaviour? In the below example, if
job.cancel()
is called, while the job is waiting for new Items from
receiveChannel
it will print out
Done
Copy code
job = launch(coroutineContext) {
                receiveChannel.consumeEach { r ->
                    output.send(r)
                }
                println("Done")
                output.close()
            }
If relevant, I do have a self contained sample, which is an alternative implementation of @hannesstruss switchMap example. Please let me know if I should post it.
v
It will not.
consumeEach
re-throws exceptions. Issue is somewhere in
switchMap
implementation (I haven’t looked at it yet)