zio
zio copied to clipboard
ZStream: Using `timeoutFail` logs an unhandled error
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
/bounty $75
~~## 💎 $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 bounty • Share on socials~~
Attempt | Started (GMT+0) | Solution |
---|---|---|
🟢 @kpritam | May 12, 2024, 6:02:05 PM | #8852 |
/attempt #8783
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@kpritam | 1 ZIO bounty | Scala, Makefile, Python & more |
Cancel attempt |
💡 @kpritam submitted a pull request that claims the bounty. You can visit your bounty board to reward.