If a dispatcher throws an exception when dispatching a coroutine, the following code will fail:
val brokenDispatcher = object : CoroutineDispatcher() {
override fun dispatch(context: CoroutineContext, block: Runnable) = TODO()
}
runBlocking<Unit> {
launch(brokenDispatcher, ) {
}
}
because of the special handling introduced in #880.
But launch(brokenDispatcher, CoroutineStart.ATOMIC) will silently hang without any errors or diagnostics, though nothing prevents us from using the same fail-fast mechanism there.
E.g. the following patch presumably addresses the issue: https://gist.github.com/qwwdfsad/d221e99eea6767bbe6f6be135373e5ff
See also: this discussion
If a dispatcher throws an exception when dispatching a coroutine, the following code will fail:
because of the special handling introduced in #880.
But
launch(brokenDispatcher, CoroutineStart.ATOMIC)will silently hang without any errors or diagnostics, though nothing prevents us from using the same fail-fast mechanism there.E.g. the following patch presumably addresses the issue: https://gist.github.com/qwwdfsad/d221e99eea6767bbe6f6be135373e5ff
See also: this discussion