zio icon indicating copy to clipboard operation
zio copied to clipboard

ZStream: Using `timeoutFail` logs an unhandled error

Open jasnross opened this issue 10 months ago • 4 comments

When I add .timeoutFail to a stream I always get an unhandled error log regardless of whether the stream timed out or not.

The log is at DEBUG level by default, but it seems like it could be misleading to see this if you have debug logs enabled.

Example:

import zio._
import zio.stream._

object StreamTimeoutExample extends ZIOAppDefault {
  override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
    Runtime.setUnhandledErrorLogLevel(LogLevel.Info)

  val stream = ZStream
    .iterate(1)(_ + 1)
    .take(5)
    .schedule(Schedule.spaced(100.millis))
    .tap(n => Console.printLine(s"Received: $n"))
    .timeoutFail(new Exception("reached timeout"))(30.seconds)

  override def run = ZIO.logDebug("Start") *> stream.runDrain
}

Expected:

No unhandled error log is emitted since the stream completed successfully

Actual:

timestamp=2024-04-22T19:20:18.607412Z level=INFO thread=#zio-fiber-16 message="Fiber zio-fiber-16 did not handle an error" cause="Exception in thread "zio-fiber-16" scala.None$: None

jasnross avatar Apr 22 '24 19:04 jasnross

/bounty $75

jdegoes avatar May 08 '24 17:05 jdegoes

~~## 💎 $75 bounty • ZIO~~

~~### Steps to solve:~~ ~~1. Start working: Comment /attempt #8783 with your implementation plan~~ ~~2. Submit work: Create a pull request including /claim #8783 in the PR body to claim the bounty~~ ~~3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts~~

~~Thank you for contributing to zio/zio!~~

~~Add a bountyShare on socials~~

Attempt Started (GMT+0) Solution
🟢 @kpritam May 12, 2024, 6:02:05 PM #8852

algora-pbc[bot] avatar May 08 '24 17:05 algora-pbc[bot]

/attempt #8783

Algora profile Completed bounties Tech Active attempts Options
@kpritam 1 ZIO bounty
Scala, Makefile,
Python & more
Cancel attempt

kpritam avatar May 12 '24 18:05 kpritam

💡 @kpritam submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar May 12 '24 23:05 algora-pbc[bot]

🎉🎈 @kpritam has been awarded $75! 🎈🎊

algora-pbc[bot] avatar Jun 04 '24 14:06 algora-pbc[bot]