firstSuccessOf

suspend fun <T> firstSuccessOf(vararg blocks: suspend CoroutineScope.() -> T): T

Runs every block concurrently and returns the result of the first one to succeed.

Unlike raceOf, a failing block does not decide the race; its failure is recorded and the remaining blocks keep running. The remaining blocks are cancelled as soon as one succeeds. If every block fails, the last observed failure is rethrown.

Cancellation: cancelling the calling coroutine cancels every block. A block that throws CancellationException counts as failed for the race but its cancellation is not swallowed inside that block's coroutine.

Throws