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

[MAUI] Duplicate SentryMauiEventProcessors #3894

Open
phunkeler opened this issue Jan 15, 2025 · 1 comment
Open

[MAUI] Duplicate SentryMauiEventProcessors #3894

phunkeler opened this issue Jan 15, 2025 · 1 comment
Labels
Bug Something isn't working

Comments

@phunkeler
Copy link
Contributor

phunkeler commented Jan 15, 2025

Package

Sentry.Maui

.NET Flavor

.NET

.NET Version

9.0.101

OS

Any (not platform specific)

SDK Version

5.0.1

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Run the Sentry.Samples.Maui app for a supported TFM
  2. Place a break point anywhere in the Sentry.Maui.Internal.SentryMauiEventProcessor.Process method
  3. Tap Throw and Capture Exception button

Expected Result

I expect only one instance of SentryMauiEventProcessor to exist and process the event.

Actual Result

Two instances of SentryMauiEventProcessor exist and both process the event.

Notes:

When a .NET MAUI app calls either of the MauiAppBuilder.UseSentry overloads, the SentryMauiOptions configurator, SentryMauiOptionsSetup, is registered with .NET’s dependency injection container twice — albeit via different means.

services.AddSingleton<IConfigureOptions<SentryMauiOptions>>(_ => new SentryMauiOptionsSetup(section));

services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>();

As a consequence, SentryMauiOptions gets configured twice (two calls to Sentry.Maui.Internal.SentryMauiOptionsSetup.Configure during MauiAppBuilder.Build), two instances of SentryMauiEventProcessor are newed-up and added to the processing pipeline (source), and both act on an event.

Adding some logging to the Process method shows:

Info: SentryMauiEventProcessor with InstanceId: 12af7053-540e-43d6-a866-37d784dde85d processed EventId: 0b6f8c02a7604555a14c08627402839a
Info: SentryMauiEventProcessor with InstanceId: 95fae520-c882-499d-8bcc-85670c331948 processed EventId: 0b6f8c02a7604555a14c08627402839a

While this doesn’t appear to have any major side-effects (that I can immediately see) it's probably something that should be fixed.

@jamescrosswell
Copy link
Collaborator

Nice catch @phunkeler ! Thanks for reporting this.

@jamescrosswell jamescrosswell added the Bug Something isn't working label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Status: No status
Status: No status
Development

No branches or pull requests

2 participants