Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors that occur during launch of AkkaHostedService get eaten / not logged #470

Open
Aaronontheweb opened this issue Jun 26, 2024 · 1 comment · May be fixed by #494
Open

Errors that occur during launch of AkkaHostedService get eaten / not logged #470

Aaronontheweb opened this issue Jun 26, 2024 · 1 comment · May be fixed by #494
Labels
akka-actor Core Akka.NET configuration options possible-bug

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? v1.5.15
Which Akka.NET Modules? Akka.Hosting

Describe the bug

Have the following code sample:

public static AkkaConfigurationBuilder AddIssueTrackingActor(this AkkaConfigurationBuilder builder)
    {
        return builder
            .AddHocon(
                $"custom-issue-tracking-mailbox {{ mailbox-type: \"{typeof(IssueTrackerMailbox).AssemblyQualifiedName}\" }}",
                HoconAddMode.Append)
            .WithActors((system, registry) =>
            {
                Actor.Props props = Akka.Actor.Props.Create<IssueTrackingActor>()
                    .WithMailbox("custom-issue-tracking-mailbox");
                IActorRef actor = system.ActorOf(props, "issue-tracking-actor");

                //BUG: we never register the IssueTrackingActor with the ActorRegistry
            })
            .AddStartup((system, registry) =>
            {
                // BUG part 2: attempt to resolve non-existent entry from registry; exception thrown
                IActorRef actor = registry.Get<IssueTrackingActor>();
                
                // Send the issues in reverse order of importance.
                // Worth bearing in mind: totally possible that a lower-priority item might get processed
                // before the higher priority ones if the actor gets scheduled and runs immediately - it's
                // not going to sit there and wait for the higher priority items to arrive before starting.
                actor.Tell(new Issue("Issue 3", "Description 3", IssuePriority.Low));
                actor.Tell(new Issue("Issue 2", "Description 2", IssuePriority.Medium));
                actor.Tell(new Issue("Issue 1", "Description 1", IssuePriority.High));
                actor.Tell(new Issue("Issue 0", "Description 1", IssuePriority.High));
                
            });
    }

You can see where I detailed the bugs on there - the registry.Get<IssueTrackingActor>(); call throws.

However, what I see when I run this without the debugger attached is just an immediate process exit with no indication that anything went wrong. This isn't a great user experience and we need to find some way of clearly communicating that a bad thing happened to the end-user.

Crashing the process and fast-exiting is probably ok, but the user has to be given an explanation for why this happened.

Expected behavior

Some kind of error message indicating what the problem was and why my process exited.

Actual behavior

Silent failure.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

Running via Rider F5 without the debugger attached - this where I get the silent exit.

When running via dotnet run on the console I get this instead:

image

Seems like everything else startup up and ran ok there, but still no error message for the failed behavior.

@Aaronontheweb Aaronontheweb added bug Something isn't working akka-actor Core Akka.NET configuration options labels Jun 26, 2024
@Arkatufus
Copy link
Contributor

Try adding this:

var hostBuilder = new HostBuilder();
hostBuilder.ConfigureLogging(builder =>
{
    builder.AddConsole();
});

@Arkatufus Arkatufus added possible-bug and removed bug Something isn't working labels Jun 28, 2024
Aaronontheweb added a commit to Aaronontheweb/Akka.Hosting that referenced this issue Sep 16, 2024
close akkadotnet#470 - application crashes and exits should always be explicitly logged someplace where they can be seen regardless of logging configuration.
@Aaronontheweb Aaronontheweb linked a pull request Sep 16, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-actor Core Akka.NET configuration options possible-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants