Skip to content

Fail fast for CoroutineStart.ATOMIC when an underlying dispatcher throws an exception #4698

Description

@qwwdfsad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions