parEvalMap deadlocks when Stream's `F` has extra error channels
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
Tested and reproduced on version 3.2.7 and 3.6.1
This happens because in parEvalMapUnordered, the results of the evalMap action are passed back to the controlling stream using a callback in F.
But when F has a failure mode other than raiseError, the Either[Throwable, Result] => ... callback can't be invoked - leading to deadlock.
The fix for this probably involves using Outcome instead of the Either-based callback.
test("Stream of IorT deadlocks on Ior.Left") {
val s = fs2
.Stream(1)
.covary[IorT[IO, String, *]]
.parEvalMapUnordered(Int.MaxValue)(_ =>
IorT(IO.pure("fail".leftIor[Int]))
)
.compile
.drain
.value
TestControl.executeEmbed(s).assertEquals(Ior.left("fail"))
}
This fails the same way when using EitherT instead of IorT
Thanks to @armanbilge and @ChristopherDavenport for your help in debugging!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the parEvalMapUnordered implementation and reproduce the supplied TestControl case with IorT, then compare it with the EitherT case. Trace how the evalMap result is sent through the F callback and evaluate the suggested Outcome-based path. Done means both failure modes complete without deadlocking and the test observes the expected Ior.Left result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100