Why is Akka Streams swallowing my exceptions?

前端 未结 3 1015
悲&欢浪女
悲&欢浪女 2021-02-04 03:38

Why is the exception in

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source

object TestExceptionHandling {
  d         


        
3条回答
  •  余生分开走
    2021-02-04 04:06

    I had similar questions when I started using akk-streams. Supervision.Decider helps but not always.

    Unfortunately it doesn't catch exceptions thrown in ActionPublisher. I see it handled, ActorPublisher.onError is called but it doesn't reach Supervision.Decider. It works with simple Stream provided in documentation.

    Errors also don't reach actor if I use Sink.actorRef.

    And for the sake of experiment I tried following sample

    val stream = Source(0 to 5).map(100 / _)
    stream.runWith(Sink.actorSubscriber(props))
    

    In this case exception was caught by Decider but never reached actor subscriber.

    Overall I think it's inconsistent behavior. I cannot use one mechanism for handling errors in Stream.

    My original SO question: Custom Supervision.Decider doesn't catch exception produced by ActorPublisher

    And here is akka issue where it's tracked: https://github.com/akka/akka/issues/18359

提交回复
热议问题