Skip to content

Wrong exception handled when starting loggers? #3571

@alexvy86

Description

@alexvy86

I'm using Akka.Net 1.3.8 on Windows (Azure App Service in particular).

I encountered an issue with an application using a custom logger (MyProject.ActorsApp.MicrosoftExtensionsLogger) that ran fine locally, but crashed when deployed to Azure App Service because of a timeout when starting the custom logger (stack trace at the bottom for reference). I was able to fix the issue by increasing the logger-startup-timeout in my HOCON file, but it threw me off that a logger configuration issue crashed the application, so I looked at the code and whether crashing is (or isn't) the intended behavior, I think there might be a bug. The var askTask = logger.Ask(new InitializeLogger(this), timeout); call a few lines above this is throwing Akka.Actor.AskTimeoutException: Timeout after 00:00:05 seconds (code here), not just cancelling the Task if the timeout is hit, so that exception just propagates without publishing the warning message in the catch block.

That said, even if the catch block executed, the instruction right after would throw a LoggerInitializationException.

So, first off I'd like to know if it's by design that a logger failure crashes the application? And independent of that, shouldn't that catch block handle either TaskCanceledException or Akka.Actor.AskTimeoutException?

Description: The process was terminated due to an unhandled exception.
Exception Info: Akka.Configuration.ConfigurationException: Logger [MyProject.ActorsApp.MicrosoftExtensionsLogger, MyProject.ActorsApp] specified in config cannot be loaded: System.AggregateException: One or more errors occurred. (Timeout after 00:00:05 seconds) ---> Akka.Actor.AskTimeoutException: Timeout after 00:00:05 seconds
   at Akka.Actor.Futures.Ask(ICanTell self, Func`2 messageFactory, IActorRefProvider provider, Nullable`1 timeout, CancellationToken cancellationToken)
   at Akka.Actor.Futures.Ask[T](ICanTell self, Func`2 messageFactory, Nullable`1 timeout, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Akka.Event.LoggingBus.AddLogger(ActorSystemImpl system, Type loggerType, LogLevel logLevel, String loggingBusName, TimeSpan timeout)
   at Akka.Event.LoggingBus.StartDefaultLoggers(ActorSystemImpl system)
---> (Inner Exception #0) Akka.Actor.AskTimeoutException: Timeout after 00:00:05 seconds
   at Akka.Actor.Futures.Ask(ICanTell self, Func`2 messageFactory, IActorRefProvider provider, Nullable`1 timeout, CancellationToken cancellationToken)
   at Akka.Actor.Futures.Ask[T](ICanTell self, Func`2 messageFactory, Nullable`1 timeout, CancellationToken cancellationToken)<---
 ---> System.AggregateException: One or more errors occurred. (Timeout after 00:00:05 seconds) ---> Akka.Actor.AskTimeoutException: Timeout after 00:00:05 seconds
   at Akka.Actor.Futures.Ask(ICanTell self, Func`2 messageFactory, IActorRefProvider provider, Nullable`1 timeout, CancellationToken cancellationToken)
   at Akka.Actor.Futures.Ask[T](ICanTell self, Func`2 messageFactory, Nullable`1 timeout, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Akka.Event.LoggingBus.AddLogger(ActorSystemImpl system, Type loggerType, LogLevel logLevel, String loggingBusName, TimeSpan timeout)
   at Akka.Event.LoggingBus.StartDefaultLoggers(ActorSystemImpl system)
   --- End of inner exception stack trace ---
   at Akka.Event.LoggingBus.StartDefaultLoggers(ActorSystemImpl system)
   at Akka.Actor.LocalActorRefProvider.Init(ActorSystemImpl system)
   at Akka.Actor.Internal.ActorSystemImpl.Start()
   at Akka.Actor.ActorSystem.Create(String name, Config config)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions