'.pauseWhen' does not respect pause signal if there is was no data available
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
The code below should just produce timeout, but it also prints 1 despite the fact that value was produced after pause:
Stream.eval(SignallingRef[IO].of(false)).flatMap { pause =>
Stream.sleep[IO](1.second).map(_ => 1).pauseWhen(pause).concurrently {
Stream.sleep[IO](500.millis).evalMap(_ => pause.set(true))
}.foreach(IO.println)
}.compile.drain.timeout(2.seconds)
FS2: 3.2.7 & 3.2.8
Scatie link: https://scastie.scala-lang.org/ZxOocFhHTK6RjuvlQ57ulw
I think, it could be fixed with either a double-checking pause state in chunks.flatMap(...) or a custom pull stage that races between next chunk pull and pause signal.
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 by reproducing the Scastie example and reading the implementation of pauseWhen, especially the chunks.flatMap(...) path mentioned in the issue. Verify that a pause signal arriving before data emission prevents that data from being printed and that the example still completes by timeout.
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
- 38/100