Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Interruption exit lost #3897

@mikearnaldi

Description

@mikearnaldi
package demo

import zio.App
import zio._
import zio.duration._
import zio.console._

object HelloWorld extends App {

  def run(args: List[String]) =
    for {
      f <- interruptWithError.fork
      _ <- f.interrupt
      _ <- f.join
    } yield (ExitCode.success)

  val interruptWithError =
    ZIO
      .sleep(1.seconds)
      .onInterrupt(for {
        _ <- putStrLn("on interrupt executed")
        _ <- ZIO.die(new Throwable("interruption"))
      } yield ())
}

This code results in the following exit:

on interrupt executed
[error] (run-main-0) zio.FiberFailure: Fiber failed.
[error] An interrupt was produced by #1.
[error] No ZIO Trace available.
[error] zio.FiberFailure: Fiber failed.
[error] An interrupt was produced by #1.
[error] No ZIO Trace available.

The error is completely lost but the finalizer is executed, this behaviour was introduced as a result of RC21 modifications of the FiberContext & ZScope.

The following PR #3883 restores the behaviour as it was pre RC21 including the trace of the errors in finalizers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions