diff --git a/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala b/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala index d541561a88..fb49f21339 100644 --- a/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala +++ b/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala @@ -1476,27 +1476,35 @@ class StreamCombinatorsSuite extends Fs2Suite { group("withTimeout") { test("timeout never-ending stream") { - Stream.never[IO].timeout(100.millis).intercept[TimeoutException] + TestControl.executeEmbed { + Stream.never[IO].timeout(100.millis).intercept[TimeoutException] + } } test("not trigger timeout on successfully completed stream") { - Stream.sleep[IO](10.millis).timeout(1.second).compile.drain + TestControl.executeEmbed { + Stream.sleep[IO](10.millis).timeout(1.second).compile.drain + } } test("compose timeouts d1 and d2 when d1 < d2") { - val d1 = 20.millis - val d2 = 30.millis - (Stream.sleep[IO](10.millis).timeout(d1) ++ Stream.sleep[IO](30.millis)) - .timeout(d2) - .intercept[TimeoutException] + TestControl.executeEmbed { + val d1 = 20.millis + val d2 = 30.millis + (Stream.sleep[IO](10.millis).timeout(d1) ++ Stream.sleep[IO](30.millis)) + .timeout(d2) + .intercept[TimeoutException] + } } test("compose timeouts d1 and d2 when d1 > d2") { - val d1 = 40.millis - val d2 = 30.millis - (Stream.sleep[IO](10.millis).timeout(d1) ++ Stream.sleep[IO](25.millis)) - .timeout(d2) - .intercept[TimeoutException] + TestControl.executeEmbed { + val d1 = 40.millis + val d2 = 30.millis + (Stream.sleep[IO](10.millis).timeout(d1) ++ Stream.sleep[IO](25.millis)) + .timeout(d2) + .intercept[TimeoutException] + } } } diff --git a/io/js/src/main/scala/fs2/io/ioplatform.scala b/io/js/src/main/scala/fs2/io/ioplatform.scala index f9d1805d4f..7086ef2be7 100644 --- a/io/js/src/main/scala/fs2/io/ioplatform.scala +++ b/io/js/src/main/scala/fs2/io/ioplatform.scala @@ -120,7 +120,9 @@ private[fs2] trait ioplatform { .concurrently( Stream.eval( F.async_[Unit](cb => - duplex.end(e => cb(e.toLeft(()).leftMap(js.JavaScriptException))) + duplex.end { e => + cb(e.filterNot(_ == null).toLeft(()).leftMap(js.JavaScriptException)) + } ) ) ) @@ -164,8 +166,11 @@ private[fs2] trait ioplatform { if (endAfterUse) Stream.exec { F.async[Unit] { cb => - F.delay(writable.end(e => cb(e.toLeft(()).leftMap(js.JavaScriptException)))) - .as(Some(F.unit)) + F.delay( + writable.end(e => + cb(e.filterNot(_ == null).toLeft(()).leftMap(js.JavaScriptException)) + ) + ).as(Some(F.unit)) } } else Stream.empty