Skip to content

Spawning a ConsistentHashPool hangs when the underlying actor type is not registered in DI container #1661

@pierre-sts

Description

@pierre-sts

Summary

Calls to Spawn on ConsistentHashPool props hang if:

  1. The underlying routee actor props are acquired through dependency injection, and
  2. The underlying routee type is not properly registered with the DI container.

The expected behavior would be an exception such as: System.InvalidOperationException: No service for type 'MyActor' has been registered.

How to reproduce the issue

Create a plain vanilla ASP NET Core Web App project with the following code:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton(provider => new ActorSystem().WithServiceProvider(provider));
// builder.Services.AddTransient<MyActor>();  <-- commenting this out makes the spawn hang

var app = builder.Build();

var actorSystem = app.Services.GetService<ActorSystem>();

var optionProps = actorSystem.DI().PropsFor<MyActor>();
var poolProps = actorSystem.Root.NewConsistentHashPool(optionProps, 2);
var poolId = actorSystem.Root.Spawn(poolProps); // <-- this is the call that hangs

app.MapGet("/", () => "Hello World!");

actorSystem.Root.Send(poolId, "hello");

app.Run();

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions