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

PopulateAsync gets stuck in while loop if any of the event upgraders throw an exception #1083

Open
baltuonis opened this issue Feb 20, 2025 · 0 comments

Comments

@baltuonis
Copy link

Here is the code that I'm using to run IReadModelPopulator

var typeList = typeof(DependencyInjection).Assembly.DefinedTypes
            .Where(type => !type.IsInterface && !type.IsAbstract && 
                           type.ImplementedInterfaces.Any(inter => inter == typeof(IReadModel))).ToList();
foreach (var x in typeList)
{
    await populator.PurgeAsync(x, ct);
}
await populator.PopulateAsync(typeList, ct);

It happens that if any of the event upgraders throw an exception will get stuck ReadModelPopulator in a while loop waiting for more events to be enqueued to _pipedEvents.

When an exception occurs it will fail on ReadModelPopulator:144, meanwhile a ReadModelPopulator:173 while loop will run for an eternity.

What's worse I was not seeing any errors in the Logging, so it took me a while to figure it out (maybe my logging levels are wrong)

I assume that event upgraders should never ever throw any exceptions (it should just skip the event and log an error, right?)

Suggestions for a fix:

  1. Make sure it catches and logs exceptions
  2. Make sure ProcessEventQueue won't run infinitely
@baltuonis baltuonis changed the title PopulateAsync gets stuck in while loop if any of the event upgraders throw PopulateAsync gets stuck in while loop if any of the event upgraders throw an exception Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant