diff --git a/core/shared/src/main/scala/fs2/internal/Scope.scala b/core/shared/src/main/scala/fs2/internal/Scope.scala index b09da9a3f3..d937061e13 100644 --- a/core/shared/src/main/scala/fs2/internal/Scope.scala +++ b/core/shared/src/main/scala/fs2/internal/Scope.scala @@ -442,7 +442,7 @@ private[fs2] final class Scope[F[_]] private ( * that caused the interruption is returned so that it can be handled. */ private[fs2] def interruptibleEval[A](f: F[A]): F[Either[InterruptionOutcome, A]] = - interruptible match { + openScope.map(_.interruptible).flatMap { case None => f.attempt.map(_.leftMap(t => Outcome.Errored(t))) case Some(iCtx) => diff --git a/core/shared/src/test/scala/fs2/StreamZipSuite.scala b/core/shared/src/test/scala/fs2/StreamZipSuite.scala index 8e1bab8c83..06536feec6 100644 --- a/core/shared/src/test/scala/fs2/StreamZipSuite.scala +++ b/core/shared/src/test/scala/fs2/StreamZipSuite.scala @@ -420,11 +420,25 @@ class StreamZipSuite extends Fs2Suite { test("#2717 - unexpected behavior of Pull") { val stream = Stream(1).as(1).scope ++ Stream(2) val zippedPull = - stream.pull.uncons1.flatMap { case Some((_, s)) => - s.zipWith(Stream(3))((_, _)).pull.echo + stream.pull.uncons1.flatMap { + case Some((_, s)) => + s.zipWith(Stream(3))((_, _)).pull.echo + case None => Pull.done } val actual = zippedPull.stream.map(identity).covary[IO].compile.toList actual.assertEquals(List((2, 3))) } + + test("#2762 - unexpected behavior of Pull") { + val stream = Stream(1).as(1) ++ Stream(2) + val zippedPull = + stream.pull.uncons1.flatMap { + case Some((_, s)) => + s.zipWith(Stream(3))((_, _)).pull.echo + case None => Pull.done + } + val actual = zippedPull.stream.evalTap(_ => IO.unit).map(identity).compile.toList + actual.assertEquals(List((2, 3))) + } } }