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

ZStream: merge and debounce are not compatible #8734

Open
artembakhanov opened this issue Apr 11, 2024 · 2 comments
Open

ZStream: merge and debounce are not compatible #8734

artembakhanov opened this issue Apr 11, 2024 · 2 comments

Comments

@artembakhanov
Copy link

I encountered an unexpected fiber interruption error when attempting to foreach on two streams merged: one debounced and the other not. Here is the min. reproducible code example (Scala 3):

import zio.*
import zio.stream.*

val stream1: UStream[Int | Unit] =
  (ZStream.succeed(0) ++ ZStream.fromZIO(ZIO.sleep(200.millis)))
    .debounce(100.millis)
val stream2: UStream[Nothing] = ZStream.empty

val effectAll = (stream1 merge stream2).runDrain

object Kek extends ZIOAppDefault:
  val run =
    for
      _ <- effectAll
        .catchAllDefect(ZIO.fail(_))
        .tapErrorCause(ZIO.logErrorCause("mmm sweet", _))
    yield ()

Expected: the application logs nothing

Actual: When I run this app, I get this in the logs:

timestamp=2024-04-11T00:31:15.544135400Z level=ERROR thread=#zio-fiber-4 message="mmm sweet" cause="Exception in thread "zio-fiber-" java.lang.InterruptedException: Interrupted by thread "zio-fiber-6"
        Suppressed: java.lang.InterruptedException: Interrupted by thread "zio-fiber-6"" location=<empty>.Kek.run file=IKILLEDHOURSLOL.scala line=16

However for some reason if you replace 100.millis with 300.millis it works just fine, ofc it is not the case with real applications.

I tried it on every possible zio version from 2.0.0 until 2.1-RC1 and it does not work.

@jdegoes
Copy link
Member

jdegoes commented May 8, 2024

/bounty $125

Copy link

algora-pbc bot commented May 8, 2024

💎 $125 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #8734 with your implementation plan
  2. Submit work: Create a pull request including /claim #8734 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio!

Add a bountyShare on socials

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

No branches or pull requests

2 participants