Skip to content

Commit

Permalink
added test for scope fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdemarGr committed Sep 10, 2024
1 parent 228763a commit 0a41938
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/shared/src/test/scala/fs2/BracketSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,22 @@ class BracketSuite extends Fs2Suite {
.flatMap(_.join) *> released.get.assert
}
}

val activeFibers = if (isJVM) 10000 else 100
test(
s"#3473 Scope.close frees it's children and it's parent's reference to itself uncancelably ($activeFibers fibers)"
) {
(0 until 4).toList.traverse_ { _ =>
val fa = IO.ref(0).flatMap { ref =>
val res = Stream.resource(Resource.make(ref.update(_ + 1))(_ => ref.update(_ - 1)))

(0 to activeFibers).toList.parTraverse_ { _ =>
val fa = res.evalMap(_ => IO.sleep(10.millis)).take(10).compile.drain
IO.race(fa, IO.sleep(90.millis))
} >> ref.get.map(assertEquals(_, 0))
}

fa
}
}
}

0 comments on commit 0a41938

Please sign in to comment.