Skip to content

SharedFlow, buffer and produceIn fusion bug. #2817

@Dominaezzz

Description

@Dominaezzz
val stream = MutableSharedFlow<Unit>()
stream
//  .onEach {} // workaround
    .buffer(0)
    .produceIn(GlobalScope)

yield() // To make sure subscription has started.

var i = 0
while (true) {
    stream.emit(Unit)
    println("Emitted $i")
    i++
}

Without the workaround, there are 64 emissions before suspension happens. There should be at most 1 emissions.

The bug is either in SharedFlow fusion or in this function that produceIn uses.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions