Skip to content

Fix receiveAsFlow not mentioning the prompt cancellation guarantee #4366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/Channels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private suspend fun <T> FlowCollector<T>.emitAllImpl(channel: ReceiveChannel<T>,
* - Flow collectors are cancelled when the original channel is [closed][SendChannel.close] with an exception.
* - Flow collectors complete normally when the original channel is [closed][SendChannel.close] normally.
* - Failure or cancellation of the flow collector does not affect the channel.
* However, if a flow collector gets cancelled after receiving an element from the channel but before starting
* to process it, the element will be lost, and the `onUndeliveredElement` callback of the [Channel],
* if provided on channel construction, will be invoked.
* See [Channel.receive] for details of the effect of the prompt cancellation guarantee on element delivery.
*
* ### Operator fusion
*
Expand All @@ -71,7 +75,8 @@ public fun <T> ReceiveChannel<T>.receiveAsFlow(): Flow<T> = ChannelAsFlow(this,
*
* - Flow collector is cancelled when the original channel is [closed][SendChannel.close] with an exception.
* - Flow collector completes normally when the original channel is [closed][SendChannel.close] normally.
* - If the flow collector fails with an exception, the source channel is [cancelled][ReceiveChannel.cancel].
* - If the flow collector fails with an exception (for example, by getting cancelled),
* the source channel is [cancelled][ReceiveChannel.cancel].
*
* ### Operator fusion
*
Expand Down