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

parEvalMap and it's variations hang on canceled effect #3486

Open
enlait opened this issue Oct 1, 2024 · 1 comment
Open

parEvalMap and it's variations hang on canceled effect #3486

enlait opened this issue Oct 1, 2024 · 1 comment
Labels

Comments

@enlait
Copy link

enlait commented Oct 1, 2024

fs2 version 3.10.2

this code does not terminate:

Stream.unit // number of elements is irrelevant, as long as there are any; does not reproduce on Stream.empty
  .covary[IO]
  .parEvalMap(2)(_ => IO.canceled)
  .compile.drain

while there is no issue with evalMap:

Stream.unit
  .covary[IO]
  .evalMap(_ => IO.canceled)
  .compile.drain

even worse, adding interruptAfter after parEvalMap does not make the code terminate:

Stream.unit
  .covary[IO]
  .parEvalMap(2)(_ => IO.canceled)
  .interruptAfter(5.seconds)
  .compile.drain

it is not necessary for all effects to be cancelled, one is enough. This also hangs:

    Stream(IO.unit, IO.canceled)
      .covary[IO]
      .parEvalMap(2)(identity)
      .compile.drain

expected behavior:

while it's not obvious what to hope for in relation to concurrently executing effects - whether they should also cancel or not - one would expect overall termination semantics to be the same across evalMap and parEvalMap. It is also difficult to reason how to work around such situation.

@enlait enlait added the bug label Oct 1, 2024
@ValdemarGr
Copy link
Contributor

I think the fix is that the line here should be:

F.start(stop.get.race(action).guarantee(releaseAndCheckCompletion))

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

No branches or pull requests

2 participants