Closed
Description
Describe the bug
A flow that uses take(1)
, onCompletion { if (it == null) awaitCancellation() }
and first()
can hang forever instead of returning the first value.
Interestingly, removing take(1)
will cause the flow to behave as expected.
Provide a Reproducer
Here is such an example:
flowOf(1)
.take(1)
.onCompletion { if (it == null) awaitCancellation() }
.first()
This code is expected to return 1
, instead if suspends forever. If you remove take(1)
it returns 1
as expected.