Counter-intuitive behavior with `interruptScope` and `IOLocal`s
Open
Nobody has claimed this yet.
- #2843 by @armanbilge — closed without merging
bug
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
Context: https://github.com/armanbilge/bayou/issues/1#issuecomment-1062827082
//> using scala "3.1.1"
//> using lib "co.fs2::fs2-core:3.2.5"
import cats.effect._
import fs2._
object Bayou extends IOApp.Simple:
// def run = s.compile.lastOrError.flatMap(IO.println) // List(2, 1)
// def run = s.scope.compile.lastOrError.flatMap(IO.println) // List(2, 1)
def run = s.interruptScope.compile.lastOrError.flatMap(IO.println) // List()
def s = Stream.eval(IOLocal(List.empty[Int])).flatMap { local =>
Stream.eval(local.update(1 :: _)).flatMap { _ =>
Stream.eval(local.update(2 :: _)).flatMap { _ =>
Stream.eval(local.get)
}
}
}
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 running the Scala 3.1.1 reproduction with fs2-core 3.2.5 and compare the plain, scoped, and interrupt-scoped stream results. Read the behavior around interruptScope and IOLocal, then establish the expected result and verify it with a regression test.
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
- Needs clarification
- Newbie friendliness
- 35/100