<@UDU9YQ3JN> what could happen is a “check and act...
# coroutines
e
@Tolriq what could happen is a “check and act” race between
if (continuation.isCancelled)
and
continuation.resumeWithException(e)
— there is no guarantee that continuation is not already cancelled when you resume it, and, according to documentation (https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-cancellable-continuation/index.html) we have the following behavior:
Invocation of resume or resumeWithException in resumed state produces IllegalStateException. Invocation of resume in cancelled state is ignored (it is a trivial race between resume from the continuation owner and outer job cancellation and cancellation wins). Invocation of resumeWithException in cancelled state triggers exception handling of passed exception.