Skip to content
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

groupWithin: inconsistent behaviour on source termination #3169

Closed
Angel-O opened this issue Mar 21, 2023 · 1 comment · Fixed by #3183 · May be fixed by #3186
Closed

groupWithin: inconsistent behaviour on source termination #3169

Angel-O opened this issue Mar 21, 2023 · 1 comment · Fixed by #3183 · May be fixed by #3186
Labels

Comments

@Angel-O
Copy link
Contributor

Angel-O commented Mar 21, 2023

fs2 version 3.6.1

scastie

While playing around with a new implementation of groupWithin I discovered a bug. The combinator doesn't handle upstream termination consistently. See below

    val finiteStream = Stream
      .range(0, 4)
      .covary[IO]
      .metered(1.second)

    val doesNotTerminate = 
        finiteStream
          .groupWithin(Int.MaxValue, 2.days) 
          .evalTap(IO.println)
          .compile
          .lastOrError.void

    val terminates =
         finiteStream
          .groupWithin(8, 2.days)
          .evalTap(IO.println)
          .compile
          .lastOrError.void

I have an idea why this is happening. I'm happy to take a look 💪🏾

The question I have though is: what's the correct behaviour here ?

  • terminating the stream when upstream terminates
  • keeping the stream alive
@Angel-O Angel-O added the bug label Mar 21, 2023
@armanbilge
Copy link
Member

I believe that when the upstream terminates, the entire stream should terminate (gracefully, i.e. no lost elements).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants