Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions core/shared/src/test/scala/fs2/concurrent/TopicSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,39 @@ class TopicSuite extends Fs2Suite {

TestControl.executeEmbed(program) // will fail if program is deadlocked
}

// https://github.com/typelevel/fs2/issues/3642
test("subscribe and close concurrently".flaky) {
val check: IO[Unit] =
for {
t <- Topic[IO, Int]
fiber <- t
.subscribe(maxQueued = 1)
.compile
.toList
.start // let the subscription race with closing
_ <- t.close
_ <- fiber.join.timeout(5.seconds) // checking termination of the subscription stream
} yield ()

check.replicateA_(100000)
}

// https://github.com/typelevel/fs2/issues/3642
test("subscribeAwait and close concurrently".flaky) {
val check: IO[Unit] =
for {
t <- Topic[IO, Int]
fiber <- Stream
.resource(t.subscribeAwait(maxQueued = 1))
.flatten
.compile
.toList
.start // let the subscription race with closing
_ <- t.close
_ <- fiber.join.timeout(5.seconds) // checking termination of the subscription stream
} yield ()

check.replicateA_(100000)
}
}